Block interview question
Decide which requests a global sliding-window rate limiter allows
- Company:
- Block
- Round:
- Phone screen
- Type:
- Coding
- Difficulty:
- Easy
- Reported:
- Q3 2025
Problem
You are given the timestamps of incoming requests in non-decreasing order, a window length window_length and a limit max_requests. Process the requests in order and return a list of booleans saying whether each request is allowed.
A request at time t is allowed if fewer than max_requests previously allowed requests have timestamps in the window (t - window_length, t]. Denied requests do not count toward later windows.
Example 1
Input: timestamps = [1, 2, 3, 4, 5, 6], window_length = 3, max_requests = 2
Output: [True, True, False, True, True, False]
At time 3 the window (0, 3] already holds the allowed requests at 1 and 2; at time 4 the window (1, 4] holds only the one at 2; at time 6 the window (3, 6] holds 4 and 5.
Example 2
Input: timestamps = [0, 0, 0, 10], window_length = 10, max_requests = 2
Output: [True, True, False, True]
The third request at time 0 is over the limit, and at time 10 the two allowed requests from time 0 are exactly window_length old, so they no longer count.
Constraints
timestampsmay be empty and is sorted in non-decreasing order.
Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern