Filter Values Above a Threshold (Set 9)

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 9) — the data. This set runs 4 cases: nums holds arrays of 40–45 items, with values from -29 to 60; limit ranges over -5–33. The hidden cases are the largest of the set.

Example 1

filterGreaterThan()
Input
nums = [29, 57, -4, -16, 38, 51, -27, 28, 21, -17, 25, -7, 27, 2, -19, -24, -17, 59, 49, 6, 34, 38, 47, 3, 12, -22, -29, 38, 30, 26, 37, 0, 10, 33, 12, 54, 44, -5, 49, -29], limit = 32
Output
[57, 38, 51, 59, 49, 34, 38, 47, 38, 37, 33, 54, 44, 49]

Why

`filterGreaterThan` returns `[57, 38, 51, 59, 49, 34, 38, 47, 38, 37, 33, 54, 44, 49]` for this input.

Example 2

filterGreaterThan()
Input
nums = [-6, -26, 51, 51, 7, -15, 19, 50, 50, 36, -2, 46, -17, -15, 0, 55, -8, 41, 9, -20, 48, 9, -10, 57, 53, 17, 31, -17, 10, 4, -6, 15, 57, 60, -15, 35, 50, 6, -13, 30, -13, -8, 35, 51], limit = 20
Output
[51, 51, 50, 50, 36, 46, 55, 41, 48, 57, 53, 31, 57, 60, 35, 50, 30, 35, 51]

Why

`filterGreaterThan` returns `[51, 51, 50, 50, 36, 46, 55, 41, 48, 57, 53, 31, 57, 60, 35, 50, 30, 35, 51]` 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.