Filter Values Above a Threshold (Set 12)

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

Example 1

filterGreaterThan()
Input
nums = [59, 52, 16, 12, 7, -10, 37, -23, -17, 46, -26, -29, -9, -19, 2, 3, -7, -14, 22, 49, 12, 1, 1, 24, 40, -30, -21, 26, -12, -8, 17, 43, 30, -14, -26, -3, 51, 34, 59, -12, 24, 3, -7, -26, 33, 55, 0], limit = -5
Output
[59, 52, 16, 12, 7, 37, 46, 2, 3, 22, 49, 12, 1, 1, 24, 40, 26, 17, 43, 30, -3, 51, 34, 59, 24, 3, 33, 55, 0]

Why

`filterGreaterThan` returns `[59, 52, 16, 12, 7, 37, 46, 2, 3, 22, 49, 12, 1, 1, 24, 40, 26, 17, 43, 30, -3, 51, 34, 59, 24, 3, 33, 55, 0]` for this input.

Example 2

filterGreaterThan()
Input
nums = [30, -25, -10, 40, 15, 55, 20, 7, 56, 21, 7, 30, 10, 35, 46, 43, 54, -25, 52, 30, 46, 16, -22, -6, -28, 58, -6, 39, -2, 19, -2, 46, 38, 38, 54, -13, 40, -17, 9, -22, -19, 2, -18, 59, 45, 12, 23, 49], limit = 36
Output
[40, 55, 56, 46, 43, 54, 52, 46, 58, 39, 46, 38, 38, 54, 40, 59, 45, 49]

Why

`filterGreaterThan` returns `[40, 55, 56, 46, 43, 54, 52, 46, 58, 39, 46, 38, 38, 54, 40, 59, 45, 49]` 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.