Company: GP_10sep
Difficulty: medium
Rate Limiter Using Token Bucket Algorithm Problem Description Implement a rate limiter using the Token Bucket algorithm. The rate limiter should control how many requests a user can make within a time period. The Token Bucket algorithm works as follows: Each user has a bucket that holds tokens Tokens are added to the bucket at a fixed rate Each request requires one token If a token is available, the request is allowed If no token is available, the request is denied Requirements: Implement a TokenBucket class with: Constructor that takes: bucket_size : maximum tokens the bucket can hold refill_rate : tokens added per second Method: allow_request(current_time) Returns: boolean (True if request allowed, False if denied) Parameters: current_time (timestamp of the request) The TokenBucket should: Start with bucket_size tokens Refill tokens based on elapsed time Never exceed bucket_size tokens Consume one token per request Input Format First line: bucket_size (integer) Second line: refill_ra