Skip to interview prep
Apexed
Problem list143 / 143

143. Count Telemetry Above a Threshold

HardRange queries

You have telemetry measurements in arrival order. For each query [left, right, threshold], count how many measurements at indexes in [left, right) are at least threshold.

Return counts in original query order. All queries are available up front. Empty ranges give zero.

Example 1

Input: measurements = [5,1,5,9,2], queries = [[0,5,5],[1,4,6],[2,2,0],[3,5,2]]
Output: [3,1,0,2]

Example 2

Input: measurements = [-3,-2,-3], queries = [[0,3,-3],[1,3,-2],[0,3,0]]
Output: [3,1,0]

Constraints

  • At most 100,000 measurements and queries each. Values and thresholds are integers in [-10⁹, 10⁹].
  • Every query satisfies 0 ≤ left ≤ right ≤ measurements.length.

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 6 hidden and sample tests.

Code runs in an isolated browser sandbox. Progress and submissions are saved on this device.

Count Telemetry Above a Threshold — coding interview practice — Apexed