Request rate counter
Your task
Implement a request rate counter. Calls arrive with strictly increasing timestamps (milliseconds). For each call, after recording its timestamp, return the number of recorded calls whose timestamp falls within the inclusive window [t - window_ms, t]. Given the window size and a list of timestamps, return a list with the count after each call. Timestamps are non-decreasing; treat equal timestamps as valid separate calls.
Examples
rate_counter(window_ms: int, timestamps: list[int]) -> list[int]Example 1
Input
rate_counter(3000, [1, 100, 3001, 3002])Output
[1, 2, 3, 3]