Menu

2747. Count Zero Request Servers
πŸ“°

2747. Count Zero Request Servers

DEV Community: phpΒ·MD ARIFUL HAQUEΒ·9 days ago
#f6CjJpDG
#devto#dev#queries#logs#output
Reading 0:00
15s threshold

2747. Count Zero Request Servers

Difficulty: Medium

Topics: Staff , Array , Hash Table , Sliding Window , Sorting , Biweekly Contest 107

You are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs , where logs[i] = [server_id, time] denotes that the server with id server_id received a request at time time .

You are also given an integer x and a 0-indexed integer array queries .

Return a 0-indexed integer array arr of length queries.length where arr[i] represents the number of servers that did not receive any requests during the time interval [queries[i] - x, queries[i]] .

Note that the time intervals are inclusive.

Example 1:

Input: n = 3, logs = [[1,3],[2,6],[1,5]], x = 5, queries = [10,11]

Output: [1,2]

Explanation:

For queries[0] : The servers with ids 1 and 2 get requests in the duration of [5, 10] . Hence, only server 3 gets zero requests.

For queries[1] : Only the server with id 2 gets a request in duration of [6,11] .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.