#933 - Number of Recent Calls
Implement a RecentCounter class that counts the number of recent requests within a certain time frame.
RecentCounter()– initializes the counter with zero requests.ping(t: number)– adds a new request at timet(strictly increasing) and returns the number of requests that have happened in the inclusive range[t - 3000, t].
| Input | Output |
|---|---|
Operations | Output |
ping(1), ping(100), ping(3001), ping(3002) | [1, 2, 3, 3] |