Code RoomRolling window rate limiter
MediumPrep Room Coding #1234

Rolling window rate limiter

CodingNetworking & APIsAlgorithms & data structuresMid–Senior~30 min

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.

0:00 of about 30 min
InputExpectedGot
[[1,2,3,4,5],3,2][true,true,false,true,true]not run yetsample