You are given a network of n nodes, and times array. Return the minimum time for all nodes to receive signal from node k. Return -1 if not all nodes are reachable.
Example 1
Input: times = [[1,2,2],[1,3,5],[2,3,1],[2,4,4],[3,4,2],[4,5,3],[3,5,7]], n = 5, k = 1
Output: 8
Explanation: The fastest arrival times from node 1 are: node 2 at 2, node 3 at 3 (through 2), node 4 at 5 (through 2 and 3), and node 5 at 8 (through 4). The last node hears the signal at time 8.
Example 2
Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
Output: 2
Explanation: From node 2, the signal reaches nodes 1 and 3 at time 1, and node 4 at time 2 (through 3). All nodes are reached by time 2.
Example 3
Input: times = [[1,2,1]], n = 2, k = 1
Output: 1
Explanation: The signal travels from node 1 to node 2 in 1 unit of time.
"When does the signal reach **every** node?" is the maximum of the shortest paths from `k` to all others. Dijkstra computes all those distances in one pass.
Run checks all cases above. Submit evaluates all test cases.