🧠 Before you code — what pattern fits?
Implement a RecentCounter class that counts recent requests within a 3000 millisecond window. ping(t) records a request at time t (strictly increasing) and returns the number of requests in [t - 3000, t].
ping(1)=1, ping(100)=2, ping(3001)=3, ping(3002)=3
🎬 Video explanation · Nick White
Your solution runs against 1 unit tests, including edge and large-value cases.
Loading...
Test console · 1 unit tests
Submit your code to run it against all 1 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.