You have a network of n nodes and a list of directed edges times where times[i] = [u, v, w] means a signal takes w time to travel from u to v. You send a signal from node k. Return the minimum time for all nodes to receive the signal. If some node is unreachable, return -1. Google asks shortest-path problems frequently given their infrastructure focus on network optimization.
For times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2: the signal reaches nodes and at time , and node at time . Answer: .
This is a shortest-path problem. What algorithm fits?
Constraints: , .