Skip to main content
Medium Graphs Medium frequency

Network Delay Time

Open on LeetCode

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

This site is free. If these guides are helping your prep, consider buying me a coffee. ☕

Support →
Buy me a coffee