Accept or Decline Queries
Hi! I made a tiny modification in the input timestamps, it is supposed to be int[], but Java says it is too large as integer, so I have to change it to String[]. Things might be a bit more complicated, but I believe you can handle it :P
Given a list of timestamped queries, you will need to accept or decline each of them, depending on the number of request from the same IP during a given window.
The queries are represented by the two arrays timestamps and ipAddresses:
timestamps, an array of integers representing the Unix timestamps of the requests.
timestamps[i] represents the ith timestamp for the ith request, in milliseconds.timestamps is sorted in non-decreasing order.ipAddresses, an array of strings representing source IP addresses.
ipAddresses[i] corresponds to the ith request's IP address.
You're also given two integers limit and timeWindow:
limit represents the maximum number of requests that can be accepted from the same IP address, within the time window.timeWindow represents the duration of the inclusive time window, in milliseconds.You must return an array of integers where the ith element of the array corresponds to the ith request. Each element of the array should equal to 1 if the ith request was accepted and 0 if it was rejected.