Given a directed weighted graph:
times[i] = [u, v, w] means a signal travels from u to v in w time units. Return the time for a signal from node k to reach all n nodes, or -1.Example 1
Input: times = [[1,2,1]], n = 2, k = 1
Output: 1
Explanation: One edge — delay of 1.
Output: 1
Explanation: One edge — delay of 1.
Example 2
Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2
Output: 2
Explanation: Signal from node 2 in 2 units.
Output: 2
Explanation: Signal from node 2 in 2 units.