Graph Theory37 sections · 1633 units
Open in Course

LeetCode 743 Network Delay Time - Intuition

Understanding the problem

The signal travels to all nodes simultaneously. The time it takes for node xx to get the signal is the shortest path from kk to xx. Run Dijkstra from source kk. Find dist[x] for all nodes.

The answer is max(dist[x]) over all xx. If any dist[x] = Infinity, return 1-1. This problem is direct Dijkstra application. No tricks, implement it correctly. Good for practice. Watch out for 11-indexed vs 00-indexed node numbering in the input.