Filter Values Above a Threshold (Set 14)

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

Example 1

filterGreaterThan()
Input
nums = [38, 23, 45, -2, -14, 40, -29, -2, -17, -22, 46, -25, -24, 36, 27, 26, 55, 41, -4, -8, 10, -16, 8, 38, 24, -4, 36, 28, 50, -30, 20, 59, -17, 60, 43, 39, -25, 7, -7, 58, 52, 22, 56, -13, 49, -15, -7, 25], limit = 11
Output
[38, 23, 45, 40, 46, 36, 27, 26, 55, 41, 38, 24, 36, 28, 50, 20, 59, 60, 43, 39, 58, 52, 22, 56, 49, 25]

Why

`filterGreaterThan` returns `[38, 23, 45, 40, 46, 36, 27, 26, 55, 41, 38, 24, 36, 28, 50, 20, 59, 60, 43, 39, 58, 52, 22, 56, 49, 25]` for this input.

Example 2

filterGreaterThan()
Input
nums = [-21, -23, 33, -30, -19, 4, 18, 39, 48, 54, 45, 26, 23, 36, 42, -22, 22, 4, 40, 2, -4, 35, -9, 41, 31, 0, 34, 55, -4, 34, 29, -7, 4, 36, -14, 42, 14, 32, 37, 47, 42, 18, 19, -29, -24, 2, 48, 17], limit = 22
Output
[33, 39, 48, 54, 45, 26, 23, 36, 42, 40, 35, 41, 31, 34, 55, 34, 29, 36, 42, 32, 37, 47, 42, 48]

Why

`filterGreaterThan` returns `[33, 39, 48, 54, 45, 26, 23, 36, 42, 40, 35, 41, 31, 34, 55, 34, 29, 36, 42, 32, 37, 47, 42, 48]` 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.