You are given a stream of timestamped requests that have already been sorted by arrival time. Each timestamp is measured in milliseconds, and each request originates from a source IP. You need to apply a sliding-window rate limit per IP and decide whether each request is accepted or rejected.
For each request at time timestamps[i] from IP ipAddresses[i], it is accepted if and only if the number of previously accepted requests from the same IP within the rolling window (timestamps[i] - timeWindow, timestamps[i]] is strictly less than limit. The timeWindow value is also measured in milliseconds.
The window is exclusive on the left: a previous accepted request at time t0 still counts at time t only while t0 + timeWindow > t (equivalently, it expires exactly timeWindow milliseconds after it was accepted; t0 + timeWindow == t counts as expired).
Rejected requests do not count toward the limit — only accepted requests are tracked.
Return a binary array where result[i] = 1 if the i-th request is accepted and result[i] = 0 if it is rejected.
IP "a" accepts requests at t=1 and t=2. At t=3 both are still in-window (1+3>3, 2+3>3), so it is rejected. At t=4 the t=1 accept has expired (1+3=4 is not >4), leaving only 2 in-window, so the 4th is accepted. At t=5 the t=2 accept has expired (2+3=5 is not >5), so the 5th is also accepted.
Each IP is tracked independently. For "x", requests at 1 and 2 are accepted, then the request at 3 is rejected. The same happens for "y" at the same timestamps — they do not interfere with each other.
timeWindow=600 milliseconds. t=1000 and t=1500 are accepted. At t=1599, both prior accepts (1000 and 1500) are still in-window (1000+600=1600 > 1599), so it is rejected. At t=1600, the t=1000 accept has expired (1000+600=1600 is not > 1600), leaving only the t=1500 accept in-window, so the limit is no longer met and t=1600 is accepted.
1 <= timestamps.length <= 10^8
timestamps.length == ipAddresses.length
0 <= timestamps[i] <= 10^9
timestamps is sorted in non-decreasing order
ipAddresses[i] is a non-empty string of length at most 50