The Velvet Rope
A medium Python mock interview question on DataDriven. Practice with AI-powered feedback, real code execution, and a hire/no-hire decision.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Interview Prompt
A request gateway throttles each client independently: within any window of `period_seconds`, one client may have at most `max_calls` requests admitted. Build a `RateLimiter(max_calls, period_seconds)` whose `allow(user_id, now)` admits a request only when that client has fewer than `max_calls` admitted requests still inside the trailing window that ends at `now` and reaches back `period_seconds`; a request that landed exactly `period_seconds` ago has already aged out, and a rejected request is never recorded against the client. The harness replays the calls through `RateLimiter_driver(label, max_calls, period_seconds, calls)`, which builds one limiter and feeds each `[user_id, timestamp]` pair from `calls` to `allow` in order, returning the list of decisions.
Summary
Some users get in. Others wait outside until the window resets.
How This Interview Works
- Read the vague prompt (just like a real interview)
- Ask clarifying questions to the AI interviewer
- Write your python solution with real code execution
- Get instant feedback and a hire/no-hire decision