Implementing a rate limiter for trading platforms
This easy Python coding problem tests whether you can build a sliding-window rate limiter — a core infrastructure component at trading venues and brokers. The task requires you to track request timestamps, expire old entries, and enforce a per-client cap in real time.
The key challenge is maintaining an efficient data structure that discards expired requests as time advances, without scanning the entire history on every call. A well-chosen approach will keep both acceptance checks and window queries fast, even under high request volume. Interviewers often probe boundary conditions: requests arriving exactly at the window edge, bursts that fill the quota instantly, and the interaction between expiry and accounting.
- Sliding-window techniques and time-based expiry
- Choosing the right data structure (list, deque, or timestamp log)
- Handling non-decreasing timestamp sequences
- State consistency across multiple query methods