Code RoomSliding window log limiter
MediumPrep Room Coding #1438

Sliding window log limiter

CodingNetworking & APIsAlgorithms & data structuresMid–Senior~25 min

Implement a sliding-window-log rate limiter allowing at most `max_req` requests within any `window`-length time window. Given a chronologically ordered list of request `timestamps`, a request at time `ts` is allowed if, after dropping all logged timestamps `<= ts - window`, fewer than `max_req` remain; if allowed, its timestamp is logged. Return a list of booleans. Timestamps are non-decreasing.

Implement
sliding_window_log(window: int, max_req: int, requests: list[int]) → list[bool]
Examples
in[10,2,[1,2,3]]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.

0:00 of about 25 min
InputExpectedGot
[10,2,[1,2,3]][true,true,false]not run yetsample