The Event Window
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-tracking service for an API needs to answer one question on demand: how many hits landed in the last five minutes. Implement a `HitCounter` whose `hit(timestamp)` records an event at the given second and whose `get_hits(timestamp)` returns how many recorded events fall inside the trailing 300-second window ending at and including `timestamp`, so a hit at exactly `timestamp - 300` has already aged out. Timestamps arrive in non-decreasing order. Then implement the graded entrypoint `event_window(operations, arguments)`: given a list of operation names (`"HitCounter"`, `"hit"`, `"get_hits"`) and a parallel list of argument lists, replay them against a single counter and return one result per operation, `None` for `"HitCounter"` and `"hit"` and the integer count for each `"get_hits"`.
Summary
A five-minute window is all that matters.
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