Your question is Client-Side API Rate Limiter. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement a client-side rate limiter for API requests. Given a list of request timestamps in non-decreasing order, an integer max_requests, and an integer window_size, return a boolean array where each value indicates whether the corresponding request should be allowed under a sliding-window policy. A request is allowed only if fewer than max_requests requests were allowed in the last window_size seconds, including the current timestamp.
def rate_limit_requests(timestamps, max_requests, window_size):