Implement a RateLimiter that allows at most maxRequests per user within a sliding window of windowSizeInSeconds.
allowRequest(userId, timestamp)returnsTrueorFalse.- Each user has an independent limit.
- Expired requests are removed; rejected requests are not counted.
- Assume timestamps arrive in nondecreasing order.
- Analyze time and space complexity.
This problem asks for a per-user rate limiter that tracks how many requests each user has made inside a sliding time window. A standard solution uses a queue for each user to store timestamps of accepted requests, removes expired entries on each call, and checks whether the remaining count is below <code>maxRequests</code>. Because timestamps are nondecreasing, each request is added and removed at most once, which leads to efficient amortized time and straightforward space usage analysis.