Code Room
CodingMediumcod-g1119
Subject SecurityLevel Mid–Senior~25 minCommon in Security · Networking & APIs · Algorithms & data structures interviewsIndustries Software development, Technology

Question

Implement a sliding-window rate limiter. Given a chronologically-ordered list of events [key, timestamp], a window size in seconds, and a 'limit' (max allowed events per key within any window), return the list of booleans indicating, for each event in order, whether it is ALLOWED. An event is allowed if the count of previously-allowed events for the same key whose timestamp is strictly greater than (timestamp - window) is less than 'limit'; allowed events are recorded, rejected events are not. Timestamps are non-decreasing.

Implement
rate_limit(events: list[list], window: int, limit: int) → list[bool]
Examples
in[[["k",1],["k",2],["k",3]],10,2]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.

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.