Pls tell erro in this code.. output order not matching
Hey @Vaibhav277
Replace line 45-53 by
for(int i=1;i<=nodes;i++){
if(i == src) continue;
auto f = dis.find(i);
if(f != dis.end()){
cout<<dis[i]<<" “;
}else{
cout<<”-1"<<" ";
}
}
We are printing like this because in map order of elements inserted can be different(shuffled).
sir after doing this change test case still not passing
please share your code
pls tell whats the error now since test case not passing
Only one correction
replace line 51 condition by f != dis.end()&&dis[i]!=INT_MAX
because if dis[i] then it also means that its unreachable from source.
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.