You are given a network of n nodes, labeled 1 to n. You are also given times, a list of travel times as directed edges. Each entry times[i] = [ui, vi, wi] means there is a directed edge from node ui to node vi with travel time wi.
You will send a signal from a given node k. Return the minimum time it takes for all the n nodes to receive the signal. If it is impossible for all the nodes to receive the signal, return -1.
1 ^ ^ 1/ \1 / \ 2---1-->3-->1-->4
Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2 Output: 2 Explanation: Signal starts at node 2, reaches nodes 1 and 3 after 1 second, then node 4 after 2 seconds.
Input: times = [[1,2,1]], n = 2, k = 2 Output: -1 Explanation: Node 2 has no outgoing edges, so node 1 never receives the signal.
1 <= k <= n <= 1001 <= times.length <= 6000times[i].length == 31 <= ui, vi <= nui != vi0 <= wi <= 100(ui, vi) are uniquetimes = [[2, 1, 1], [2, 3, 1], [3, 4, 1]], n = 4, k = 2