Skip to content

Practice The Time When the Network Becomes Idle

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2039
LeetCode Problem

The Time When the Network Becomes Idle

Problem Statement

There are patience.length servers, and edges[i] = [u,v] is an undirected connection. Server 0 is the master in a connected undirected graph. At second 0, every other server sends a message along a shortest path; each edge takes one second. The master instantly replies along the reverse path. Until its first reply arrives, server i resends every patience[i] seconds, checking arrivals before resending at that second. Existing messages still receive replies. Return the earliest second with no messages traveling or arriving anywhere.

Source: The Time When the Network Becomes Idle on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
edges = [[0,1],[1,2]], patience = [0,2,1]
Output
8

# Example 2

Input
edges = [[0,1],[0,2],[1,2]], patience = [0,10,10]
Output
3

Constraints

n == patience.length
2 <= n <= 10^5
patience[0] == 0
1 <= patience[i] <= 10^5 for 1 <= i < n
1 <= edges.length <= min(10^5, n * (n - 1) / 2)
edges[i].length == 2
0 <= ui, vi < n
ui != vi
There are no duplicate edges.
Each server can directly or indirectly reach another server.

Related LeetCode Problems

Practice more problems similar to The Time When the Network Becomes Idle.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.