Asked at
Number Of Recent Calls
EasyVerifiedQueueSliding Window~12 min
Given calls, an increasing array of ping timestamps in milliseconds, return an array where each entry is the count of pings within the inclusive range [t - 3000, t] for the ping at time t.
The input arrives as a single array calls. Slide a queue and drop timestamps older than the window.
Examples
in[1, 100, 3001, 3002]
out[1, 2, 3, 3]
At 3002, pings 100, 3001, 3002 fall in [2, 3002].
in[1, 2, 3]
out[1, 2, 3]
All pings stay within 3000 ms of each other.
Constraints
- 1 ≤ calls.length ≤ 10⁴
- 1 ≤ calls[i] ≤ 10⁹
- calls is strictly increasing.
Get help
🔑
Sign in to solve
Sign in to write, run, and submit your solution — and to pick up where your iOS flow left off.