Filter Values Above a Threshold (Set 10)

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

Example 1

filterGreaterThan()
Input
nums = [-7, 29, -2, 47, 35, -19, -5, -18, 16, 52, 10, -11, 53, 36, 51, -2, 50, -21, 53, 3, 58, -8, 55, 49, -2, 1, 47, 9, -19, 19, -1, 32, -20, 27, 21, 7, 2, 47, 56, 35], limit = -2
Output
[29, 47, 35, 16, 52, 10, 53, 36, 51, 50, 53, 3, 58, 55, 49, 1, 47, 9, 19, -1, 32, 27, 21, 7, 2, 47, 56, 35]

Why

`filterGreaterThan` returns `[29, 47, 35, 16, 52, 10, 53, 36, 51, 50, 53, 3, 58, 55, 49, 1, 47, 9, 19, -1, 32, 27, 21, 7, 2, 47, 56, 35]` for this input.

Example 2

filterGreaterThan()
Input
nums = [39, 1, 35, -3, 43, -16, -19, -10, 10, 20, 1, -28, 5, -25, -10, 5, 18, -13, 14, 12, 55, -12, 33, -4, 29, 57, -9, 4, 28, -30, -14, 40, 57, 50, 42, 6, 10, -22, 58, -18, 46, 19], limit = -4
Output
[39, 1, 35, -3, 43, 10, 20, 1, 5, 5, 18, 14, 12, 55, 33, 29, 57, 4, 28, 40, 57, 50, 42, 6, 10, 58, 46, 19]

Why

`filterGreaterThan` returns `[39, 1, 35, -3, 43, 10, 20, 1, 5, 5, 18, 14, 12, 55, 33, 29, 57, 4, 28, 40, 57, 50, 42, 6, 10, 58, 46, 19]` 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.