Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a rate limiter using the token bucket algorithm.

Hard

Problem 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 } }
Log in or sign up to run or submit your code.Log inSign up
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