It is giving correct output in the sample test case while compiling but while submitting it shows the wrong answer, why?
Dijkstra algorithm
How do we get the unreachable node and calculate the sum -1. I guess by using dfs and dfs helper like in connected components code. But I am unable to do it
hi @mohitsethia, your code is correct , you just need to handle the part of unreachable nodes, dist[i] = INT_MAX means that the node is not reachable from src node so whenever you find dist[i] = INT_MAX you can output -1 , also in your code , when you are initializing dist map to INT_MAX, you need to initialize for 1 to n , since there can be isolated nodesso taking the key value from m does;nt include all the nodes also you have to output based on increasing order of their labels i.e 1 to n .
i have corrected your code here :-
refer to the code here :- https://ide.codingblocks.com/s/233088
In case of any doubt feel free to ask 
I got it thanks 
Actually I was thinking in some other way of using connected components method, and couldn’t think of this easy way.
I asked it using ask doubt section and now I couldn’t find it there, Where will I find the option to mark doubt as resolved?