The Time When the Network Becomes Idle
specialist · 795 · lc medium +31 · verified · 55.4% accepted · 742 likes · top 49%
Description
A network has n servers labeled 0 to n - 1, connected by undirected edges edges (each edge allows instant message passing in one second). Server 0 is the master; all others are data servers. At second 0, every data server sends its message to the master via the shortest path. The master replies instantly along the same path. If a data server i has not received a reply and patience[i] seconds have elapsed since its last send, it resends the message — repeating every patience[i] seconds until the reply arrives. Return the earliest second at which the network becomes completely idle (no messages in transit or arriving).
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Code