Filter Values Above a Threshold (Set 13)

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

Example 1

filterGreaterThan()
Input
nums = [6, 11, 42, 15, -7, 13, 21, 58, 7, 19, -9, 6, 39, -11, 5, -20, -5, 53, 7, -18, 14, -20, -12, -24, 24, -22, -9, -20, -20, -14, 55, -19, 14, 44, 1, 39, -3, 25, -19, 56, 2, 56, 28, 18, 35, 14, -16, 3], limit = -2
Output
[6, 11, 42, 15, 13, 21, 58, 7, 19, 6, 39, 5, 53, 7, 14, 24, 55, 14, 44, 1, 39, 25, 56, 2, 56, 28, 18, 35, 14, 3]

Why

`filterGreaterThan` returns `[6, 11, 42, 15, 13, 21, 58, 7, 19, 6, 39, 5, 53, 7, 14, 24, 55, 14, 44, 1, 39, 25, 56, 2, 56, 28, 18, 35, 14, 3]` for this input.

Example 2

filterGreaterThan()
Input
nums = [51, 54, 14, -29, -19, 41, -27, 56, 15, 11, -15, 12, -9, 57, -13, -26, 49, 40, 20, 53, 52, -14, 2, 9, -3, -1, -13, -5, -9, -21, 41, -20, -22, -13, 24, 5, -28, -27, 9, -5, 48, -20, -9, -13, 0, -29, 3, 33], limit = 2
Output
[51, 54, 14, 41, 56, 15, 11, 12, 57, 49, 40, 20, 53, 52, 9, 41, 24, 5, 9, 48, 3, 33]

Why

`filterGreaterThan` returns `[51, 54, 14, 41, 56, 15, 11, 12, 57, 49, 40, 20, 53, 52, 9, 41, 24, 5, 9, 48, 3, 33]` 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.