Loading...
Given n nodes and times[i] = [u, v, w] (directed edge with weight), send a signal from node k. Return the minimum time for all nodes to receive the signal. Return -1 if impossible.
Input: first line = n k, second = edges as u:v:w comma-separated.
4 2 2:1:1,2:3:1,3:4:1
2
4 2 indicates there are n=4 nodes and the signal is sent from node k=2.2:1:1, 2:3:1, and 3:4:1, which means the signal travels from node 2 to node 1 in 1 unit of time, from node 2 to node 3 in 1 unit of time, and from node 3 to node 4 in 1 unit of time.