Tap here to switch tabs
Problem
Submissions

Problem: Count Zero Request Servers

med
30 min
Try to solve the Count Zero Request Servers problem.

Statement

You are given an integer n representing the total number of servers, indexed from 11 to n. You are also given a 22D integer array logs where logs[i] = [server_id, time] indicates that the server with identifier server_id received a request at time time.

Additionally, you are given an integer x and an integer array queries.

For each query queries[j], determine the count of servers that received zero requests in the time interval [[ queries[j] −x,- x, queries[j] ]] (inclusive).

Return an array ans of length queries.length where ans[j] is the answer to the jextthj^{ ext{th}} query.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq logs.length ≤105\leq 10^5

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • logs[i].length =2= 2

  • 1≤1 \leq logs[i][0] ≤\leq n

  • 1≤1 \leq logs[i][1] ≤106\leq 10^6

  • 1≤1 \leq x ≤105\leq 10^5

  • x << queries[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Zero Request Servers

med
30 min
Try to solve the Count Zero Request Servers problem.

Statement

You are given an integer n representing the total number of servers, indexed from 11 to n. You are also given a 22D integer array logs where logs[i] = [server_id, time] indicates that the server with identifier server_id received a request at time time.

Additionally, you are given an integer x and an integer array queries.

For each query queries[j], determine the count of servers that received zero requests in the time interval [[ queries[j] −x,- x, queries[j] ]] (inclusive).

Return an array ans of length queries.length where ans[j] is the answer to the jextthj^{ ext{th}} query.

Constraints:

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq logs.length ≤105\leq 10^5

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • logs[i].length =2= 2

  • 1≤1 \leq logs[i][0] ≤\leq n

  • 1≤1 \leq logs[i][1] ≤106\leq 10^6

  • 1≤1 \leq x ≤105\leq 10^5

  • x << queries[i] ≤106\leq 10^6