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
An API gateway throttles each client independently: within any `window_ms` window a client may keep at most `max_requests` accepted calls. The `operations` list opens with `['init', max_requests, window_ms]` to configure the limiter and is followed by `['is_allowed', client_id, timestamp]` decisions; return one result per entry, `None` for the configure step and then `True` or `False` for each decision. A call is allowed only when the client has fewer than `max_requests` accepted calls still inside the half-open window `(timestamp - window_ms, timestamp]`, and a denied call is never recorded, so a throttled client becomes eligible again as soon as its earlier accepted calls age out.
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.