The Throttle Wall
A hard Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- hard
- Seniority
- L4
Problem
Implement RateLimiter(max_requests, window_ms). is_allowed(client_id, timestamp) returns True when the client has strictly fewer than max_requests recorded in the window (timestamp - window_ms, timestamp], then records the current timestamp. Test harness: ['init', max, window] then ['is_allowed', client, ts] calls; returns parallel results (None for init, True/False for each is_allowed).
Summary
Stop the abusers. Let the rest through.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.