Code RoomSliding window log rate limiter
MediumPrep Room Coding #1015

Sliding window log rate limiter

CodingNetworking & APIsAlgorithms & data structuresMid–Senior~30 min

Simulate a sliding-window-log rate limiter. You are given `requests`, a list of integer arrival timestamps in non-decreasing order, a window length `window`, and a `limit`. A request at time t is ALLOWED iff, counting it, at most `limit` requests fall within the half-open window (t - window, t] (i.e. timestamps strictly greater than t-window and up to t, among requests that were themselves allowed). Rejected requests do not occupy the window. Return a list of booleans, one per request, indicating allowed (True) or rejected (False).

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

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