Approach Summary
Dijkstra from source node k. Return the maximum distance among all nodes; if any node is unreachable return -1.
How to Recognize This Pattern
- "Minimum time for signal to reach all nodes"
- Weighted directed graph → Dijkstra (min-heap)
Complexity Analysis
Time Complexity
O(E log V)
Space Complexity
O(V + E)
Tags
DFS BFS Graph Heap Shortest Path