Dijkstra Shortest Path
Find shortest path using priority queue.
Examples
Input: [5,[[0,1,2],[0,2,4],[1,2,1],[1,3,7],[2,4,3],[3,4,1]],0]
Output: [0,2,3,9,6]
Input: [5,[[0,1,2],[0,2,4],[1,2,1],[1,3,7],[2,4,3],[3,4,1]],0]
Output: [0,2,3,9,6]
Hints
Use a min-heap (priority queue) to always process the nearest node.
Track distances, initialized to infinity except for the source.
Relax edges when a shorter path is found.
Dijkstra Shortest Path
Find shortest path using priority queue.