Code Room
CodingHardcod-g448
Subject Rate limiter designLevel Senior–Staff~35 minCommon in Networking & APIs interviewsIndustries Software development

Question

Simulate a per-key fixed-window counter limiter. You get `requests` as a list of [key, timestamp] pairs in non-decreasing timestamp order, a `window` size, and a `limit`. Windows are aligned to multiples of `window`: the window index for time t is t // window. Within each key's current aligned window, the first `limit` requests are ALLOWED and the rest REJECTED; the counter resets when a request lands in a new window for that key. Return the list of booleans in input order.

Implement
fixed_window_limiter(requests: list[list], window: int, limit: int) → list[bool]
Examples
in[[["a",0],["a",1],["a",2],["a",10]],10,2]out[true,true,false,true]
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.