Shortest path Dijkstra
Your task
Given n nodes labeled 0..n-1 and a list of directed weighted edges [u, v, w] with w >= 0, find the shortest-path distance from node src to every node. Return a list of length n where index i is the distance to node i, or -1 if unreachable. Use a priority queue. The graph may have multiple edges between the same pair.
Examples
dijkstra(n: int, edges: list[list[int]], src: int) -> list[int]Example 1
Input
dijkstra(5, [[0, 1, 4], [0, 2, 1], [2, 1, 2], [1, 3, 1], [2, 3, 5]], 0)Output
[0, 3, 1, 4, -1]