Meta’s internal fleet service needs to push a config update from one datacenter to all others over directed network links. Given a directed weighted graph, return the time it takes for the update to reach every node from a starting node, or -1 if some node is unreachable.
Implement a function that takes:
times: a list of directed edges, where each edge is [u, v, w]n: the number of nodes labeled from 1 to nk: the starting nodeReturn an integer: the minimum time required for all nodes to receive the update. If any node cannot be reached from k, return -1.
Example 1
times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 221 is reached in 1, node 3 in 1, and node 4 in 2. The last node receives the update at time 2.Example 2
times = [[1,2,1]], n = 2, k = 11Example 3
times = [[1,2,1]], n = 2, k = 2-11 cannot be reached from node 2.1 <= n <= 10^40 <= len(times) <= 2 * 10^41 <= u, v <= nu != v0 <= w <= 100