Code Room
CodingMediumcod-g226
Subject Rate limiter designLevel Mid–Senior~30 minCommon in Networking & APIs interviewsIndustries Software development

Question

Implement a per-key fixed-window counter rate limiter. Given a list of (key, ts) requests in non-decreasing ts order (integer seconds), a 'limit', and a 'window' size in seconds, each request maps to the fixed window index ts // window. A request is allowed if, for its key and its window index, fewer than 'limit' requests have already been allowed; allowed requests increment that key+window counter. Windows are independent and counters do not carry over. Return a list of booleans aligned to the input. Empty input returns an empty list.

Implement
fixed_window(requests: list[tuple], limit: int, window: int) → list[bool]
Examples
in[[["a",0],["a",1],["a",2]],2,10]out[true,true,false]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.