Code Room
CodingMediumcod-g668
Subject Rate limiter designLevel Mid–Senior~30 minCommon in Networking & APIs · Algorithms & data structures interviewsIndustries Software development, Technology

Question

Given a chronological list of request timestamps (integer seconds, non-decreasing) for a single client, a window length W seconds, and a limit of L requests per rolling window, implement a sliding-window rate limiter. A request at time t is allowed only if, counting it, the number of allowed requests in the half-open interval (t-W, t] does not exceed L; otherwise it is rejected and does NOT count toward future windows. Return a list of booleans, one per request, indicating allowed (True) or rejected (False).

Implement
sliding_window_limiter(timestamps: list[int], window: int, limit: int) → list[bool]
Examples
in[[1,2,3,4,5],3,2]out[true,true,false,true,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.