Code RoomSliding window rate limiter
MediumPrep Room Coding #197

Sliding window rate limiter

CodingNetworking & APIsAlgorithms & data structuresMid–Senior~25 min

Implement a per-IP sliding-window rate limiter. You are given a list of events [ip, timestamp] in non-decreasing timestamp order. Each IP may have at most `limit` accepted events within any window of `window` seconds (an event at time t counts events in the half-open interval (t-window, t]). Process events in order: return a list of booleans, True if the event is accepted (and thus counts toward the limit), False if it is rejected. Rejected events do not consume quota.

Implement
rate_limit(events: list[list], limit: int, window: int) → list[bool]
Examples
in[[["a",1],["a",2],["a",3]],2,10]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
[[["a",1],["a",2],["a",3]],2,10][true,true,false]not run yetsample