Design a counter that returns how many calls happened in the last 3000 milliseconds each time a new call arrives. Pattern focus: Circular Queue (Ring Buffer). Remove stale timestamps from the front and keep only the active time window.
t = array of call timestamps in milliseconds
count of calls in the last 3000 milliseconds after each timestamp
Example 1:
Input:
t = [1,100,3001,3002]
Output:
[1,2,3,3]
Explanation:
Each ping counts how many timestamps fall within the last 3000 ms.
Example 2:
Input:
t = [1,2,3,4,3000]
Output:
[1,2,3,4,5]
Explanation:
All calls remain in the active 3000 ms window.