Implement a rate limiter using the token bucket algorithm.
HardProblem Statement
Implement a rate limiter using the token bucket algorithm.
Sample Input
Bucket Capacity: 5; Tokens Added per Second: 2; Requests: 5 at t=0, 2 at t=1, 1 at t=3
Sample Output
t=0: 5 requests processed t=1: 2 requests processed t=3: 1 request processed Remaining tokens: 3
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
using System;
class TokenBucketRateLimiter
{
static void Main()
{
// Implement a token bucket rate limiter
}
}
Input
Bucket Capacity: 5; Tokens Added per Second: 2; Requests: 5 at t=0, 2 at t=1, 1 at t=3
Expected Output
t=0: 5 requests processed t=1: 2 requests processed t=3: 1 request processed Remaining tokens: 3