Please check my code


it is giving wrong ans in one test case

I made changes to your code, please see https://ide.codingblocks.com/s/243195

thank you sir
but please tell me why do we need to change that for loop and why mine doesnt work

Some nodes may be completely disconnected , like an isolated node, for them you were not setting dist[i]=INT_MAX, so I ran a loop for all nodes.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.