Given a sorted array timestamp representing the timestamps of incoming requests, return an array where the i-th element represents the number of requests received in the previous 10 minutes, including the current request.
For every request at time timestamp[i], count all requests whose timestamps lie within the 10-minute window ending at timestamp[i].
n representing the number of requests.timestamp of size n, where timestamp[i] represents the timestamp of the i-th request.Return an integer array ans of size n, where:
ans[i] = number of requests with timestamp >= timestamp[i] - 10 and <= timestamp[i]
Input:
timestamp = [1, 2, 3, 11, 12, 13, 20]
Output:
[1, 2, 3, 2, 2, 3, 1]
For timestamp[i] = 13, the previous 10-minute window is:
[3, 13]
Requests occurred at:
3, 11, 12, 13
So the answer is 4.
Note: The exact boundary interpretation should be confirmed from the original Visa statement. If "previous 10 minutes" means strictly more than
t-10, use(t-10, t]; if inclusive, use[t-10, t].
Willingness • Pending
Willingness • Pending
Willingness • Pending
VISA • Pending