Getting 1 test case wrong

i am getting 1 test case wrong


this is my solution

Hey @singh.pankhil40
Failing for test cases like this :

1
4 2
1 2
3 4
1
Graph is 1<->2 3<->4
So u will never visit 3 and 4 so ans for them is -1 as well.

To rectify this do this

for(int i=1;i<=n;i++)
{
if(dist[i]==INT_MAX){
cout<<-1<<" “;
continue;
}
if(dist[i]!=0)
{
cout<<dist[i]<<” ";
}
}

Hey @singh.pankhil40
I am marking this as resolved from my side , if u still dont have clarity in this then feel free to message me.
:slight_smile:

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.

hello @singh.pankhil40
u have reopend the doubt , pls let mw know what issue u r facing now