Implement the RecentCounter class, which counts how many requests arrived within a recent time window.
RecentCounter() starts with no requests.ping(t) records a new request at time t (in milliseconds; t is strictly larger on every call) and returns how many requests, this one included, arrived in the inclusive window [t - 3000, t].This is the classic sliding-window queue pattern — push the new time, pop times that fell out of the window, then the queue size is the answer.
Each example lists the calls in order, then each call's arguments, then each call's result (null for the constructor).
1 ≤ t ≤ 10⁹t is strictly larger than the previous one.10⁴ calls are made to ping.Keep a queue of timestamps. On each ping, pop from the front while front < t - 3000.
[null,1,2,3,3]