An ingestion API throttles each key to a fixed number of calls in a trailing window. Replay a day of traffic and decide what the limiter would have done, so a proposed limit can be judged before it is turned on.
Each request has request_id (int), api_key (str) and ts, a YYYY-MM-DD HH:MM:SS string.
Return one dict per request, in the order they were processed, with keys in this order:
request_id, decision
ts; break ties on the same ts by ascending request_idlimit allowed requests whose timestamp is strictly greater than ts - window_secondsdecision is ALLOW or DENYwindow_seconds old has left the windowapi_key; keys never interferelimit2
requests| ts | api_key | request_id |
|---|---|---|
| 2026-04-01 09:00:00 | k1 | 1 |
| 2026-04-01 09:00:10 | k1 | 2 |
| 2026-04-01 09:00:20 | k1 | 3 |
| 2026-04-01 09:01:05 | k1 | 4 |
window_seconds60
| request_id | decision |
|---|---|
| 1 | ALLOW |
| 2 | ALLOW |
| 3 | DENY |
| 4 | ALLOW |
limit1
requests| ts | api_key | request_id |
|---|---|---|
| 2026-04-02 09:00:00 | k1 | 1 |
| 2026-04-02 09:00:01 | k2 | 2 |
| 2026-04-02 09:00:05 | k1 | 3 |
window_seconds30
| request_id | decision |
|---|---|
| 1 | ALLOW |
| 2 | ALLOW |
| 3 | DENY |
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.