Leaky bucket rate limiter
Your task
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.
Examples
leaky_bucket(capacity: int, leak_rate: int, events: list[list[int]]) -> list[bool]Example 1
Input
leaky_bucket(10, 1, [[0, 5], [0, 5], [0, 1]])Output
[True, True, False]