Complete the code to represent the token bucket refill logic.
tokens = min(capacity, tokens + [1] * elapsed_time)
The refill rate is multiplied by elapsed time to add tokens to the bucket.
Complete the code to check if a request can be allowed in the leaky bucket algorithm.
if queue_size < [1]: allow_request()
The queue size must be less than the bucket capacity to allow a new request.
Fix the error in the token bucket token consumption logic.
if tokens >= [1]: tokens -= request_size
We must check if tokens are enough to cover the request size before consuming.
Fill both blanks to implement the leaky bucket leak rate update.
leaked = min(queue_size, [1] * [2]) queue_size -= leaked
The leak amount is rate multiplied by elapsed time, limited by the current queue size.
Fill all three blanks to implement a token bucket request check and update.
if tokens >= [1]: tokens -= [2] allow = [3]
Check if tokens cover request size, subtract request size, and allow the request.
