Given times[i] = [ui, vi, wi] (source, target, travel time) for n nodes labeled 1 to n, and a starting node k. Return the minimum time for all nodes to receive the signal. If impossible, return -1.
Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
Output: 2
Topics: graphs
Asked by: Amazon, Google, Meta, Microsoft
Time complexity: O(E log V). Space complexity: O(V + E).