Problem
A network has n nodes with the numbers 1 to n. The list times gives the directed edges of the network. A directed edge goes in one direction only.
Each item [u, v, w] in times is an edge from node u to node v. A signal needs w time units to go along this edge.
You send a signal from node k at time 0. Return the time at which all n nodes have the signal. If some node can never get the signal, return -1.
Example 1
- Input:
- times = [[1,2,4],[1,3,1],[3,2,2],[2,4,1]], n = 4, k = 1
- Output:
- 4
- Explanation:
- The signal gets to node 3 at time 1 and to node 2 at time 3, through node 3. Node 4 gets the signal last, at time 4.
Example 2
- Input:
- times = [[2,1,3]], n = 2, k = 1
- Output:
- -1
- Explanation:
- The only edge goes from node 2 to node 1. The signal from node 1 cannot get to node 2.
Constraints
- 1 <= k <= n <= 100
- 1 <= times.length <= 6000
- times[i].length == 3
- 1 <= u, v <= n
- u != v
- 0 <= w <= 100
- All the pairs (u, v) are unique
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Cheapest Flights Within K Stops
Coding · Breadth-First Search · Depth-First Search · Dynamic Programming
- Evaluate Division
Coding · Array · Bellman–Ford Algorithm · Breadth-First Search
- Alien Dictionary
Coding · Array · Breadth-First Search · Depth-First Search
- Course Schedule
Coding · Breadth-First Search · Depth-First Search · Directed Acyclic Graph
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
CrowdStrike
Leetcode 743. Network Delay Time
Reported Apr 27, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 1 record
NVIDIA
Network Delay Time
Reported date not specified · Source window: 6mo
Source snapshot: Oct 20, 2026
Source frequency score: 85.3. This is not an interview probability.
View source