n servers numbered 1 to n. The log logs records traffic: logs[i] = [server, time] means server server received a request at time time.
You are also given a window length window and a list of moments moments. For each moment q, count the servers that received no requests during the time interval [q - window, q] (both ends inclusive). If q - window is below 1, the interval simply starts before the earliest possible request.
Return the answers in the same order as moments.n=3, logs=[[1, 2], [3, 7], [1, 9]], window=3, moments=[5, 9] → [2, 1]
Window [2, 5] contains only server 1's request at time 2, so servers 2 and 3 are idle. Window [6, 9] contains requests to servers 3 and 1, so only server 2 is idle. The answer is [2, 1].
n=2, logs=[[2, 10], [2, 11]], window=4, moments=[20, 12] → [2, 1]
Window [16, 20] has no requests, so both servers are idle. Window [8, 12] has server 2 busy, so only server 1 is idle. Answers follow the query order: [2, 1].
n=1, logs=[[1, 5]], window=5, moments=[10, 11] → [0, 1]
n ≤ 10⁵n, 1 ≤ time ≤ 10⁶window ≤ 10⁵moments[i] ≤ 10⁶n=3, logs=[[1, 2], [3, 7], [1, 9]], window=3, moments=[5, 9]
[2, 1]
Run checks the first 3 tests in your browser. Submit checks all 95 tests on the server, hidden ones included.