Code Room
CodingMediumcod-g1146
Subject Networking protocolsLevel Mid–Senior~22 minCommon in Networking & APIs interviewsIndustries Telecom, Software development

Question

Simulate a leaky-bucket rate limiter. The bucket has an integer 'capacity' and leaks 'leak_rate' units per second (continuously). Process 'events', a list of [time, amount] with non-decreasing integer times. Before each event, leak (time - last_time) * leak_rate units (the level never drops below 0). An event is accepted if level + amount <= capacity (then add amount); otherwise rejected (level unchanged). Return a list of booleans, one per event. Times start at 0.

Implement
leaky_bucket(capacity: int, leak_rate: int, events: list[list[int]]) → list[bool]
Examples
in[10,1,[[0,5],[0,5],[0,1]]]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.