Filter Values Above a Threshold (Set 7)

Easy

Given an array of integers nums and a limit, return the values that are strictly greater than limit, in their original order.

Filter Values Above a Threshold (Set 7) — the data. This set runs 4 cases: nums holds arrays of 28–45 items, with values from -28 to 60; limit ranges over -19–40. The hidden cases are the largest of the set.

Example 1

filterGreaterThan()
Input
nums = [47, 26, 35, 48, -26, 53, 21, 2, -23, -19, -16, -26, -9, 25, 57, 41, 47, -18, -19, 6, -20, -23, 4, 34, 14, -14, -18, 59, -21, -16, 13, 54, 49, 22, 26, 45, 32, 31, 6, 39, 48, -15, 2], limit = 40
Output
[47, 48, 53, 57, 41, 47, 59, 54, 49, 45, 48]

Why

`filterGreaterThan` returns `[47, 48, 53, 57, 41, 47, 59, 54, 49, 45, 48]` for this input.

Example 2

filterGreaterThan()
Input
nums = [4, -28, 56, 0, 21, 5, 0, -24, 49, 39, 38, 53, -13, 25, -18, 5, 50, 35, -13, 24, -2, 29, 31, 34, 46, -14, 8, 31], limit = 1
Output
[4, 56, 21, 5, 49, 39, 38, 53, 25, 5, 50, 35, 24, 29, 31, 34, 46, 8, 31]

Why

`filterGreaterThan` returns `[4, 56, 21, 5, 49, 39, 38, 53, 25, 5, 50, 35, 24, 29, 31, 34, 46, 8, 31]` for this input.
Constraints
0 <= nums.length <= 10^5
-10^4 <= nums[i], limit <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

Arrays

Implement filterGreaterThan in the editor and return the answer — printing it is never graded.