
'N' = 3, 'M' = 3, 'edges' = [0, 1, 2], [1, 2, 3], [0, 2, 6]].

Distance (0 to 0) = 0.
Distance (0 to 1) = 2.
Distance (0 to 2) = 0->1 + 1->2 = 2+3 = 5.
So our answer is [0, 2, 5].
The first line contains two integers, 'N', and 'M'.
The next 'M' lines contain three integers each, 'u', 'v', and 'w', representing there is a directed edge from 'u' to 'v' of weight 'w'.
The only line contains an array that stores the distance(sum of weights) of the shortest path from vertex 0 to all vertices, and if it is impossible to reach any vertex, then assign -1 as distance.
You don’t need to print anything, it has already been taken care of. Just complete the given function.
Algorithm: