LeetCode 743 ·
Medium
Network Delay Time
From a source node, find the time for a signal to reach all nodes (or −1).
Try it
Step through the core mechanic. The simulator below runs the graph algorithms shape this problem is built on.
Walk the pattern
No dedicated step-through for this one yet. The shape is Graph algorithms — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.
The approach
Dijkstra from the source: a min-heap of (distance, node) pops the nearest unsettled node and relaxes its edges. The answer is the maximum settled distance, or −1 if any node is unreachable.
| Aspect | Value |
|---|---|
| Pattern | Graph algorithms |
| Recognise it by | Single-source shortest path with weights — Dijkstra. |
| Time complexity | O(E log V) |
| Space complexity | O(V+E) |
| Difficulty | Medium |
Who asks it
Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.