Design and implement a simple rate limiter for an API endpoint. The rate limiter should allow a maximum of n requests per time_window seconds for a given user. If a user exceeds this limit, subsequent requests should be denied until the next time window.
n: Integer representing the maximum number of requests allowed.time_window: Integer representing the time window in seconds.user_id: String representing the unique identifier for the user.True if the request is allowed, otherwise return False.Example 1:
Input: n = 5, time_window = 10, user_id = 'user1'
Output: True (1st request allowed)
Example 2:
Input: n = 5, time_window = 10, user_id = 'user1' (after 5 requests)
Output: False (6th request denied)
1 <= n <= 1001 <= time_window <= 601 <= user_id.length <= 100