Network Delay Time
Medium
Topics
You are given directed weighted edges times where times[i] = [u, v, w], n nodes labeled 1..n, and a source k. Return the time for all nodes to receive a signal from k, or -1 if some node is unreachable.
Example 1
Input: times = [[2,1,1],[2,3,1],[3,4,1]], n = 4, k = 2 Output: 2
Example 2
Input: times = [[1,2,1]], n = 2, k = 2 Output: -1
Constraints
- 1 <= n <= 100
- 1 <= times.length <= 6000
- The graph is directed with positive weights.
Run ⌘' · Submit ⌘⏎