Why am I getting the wrong answer for test cases but correct for sample input

Hi @Anchal
You are getting wrong answer because in your when for every pair input of v and u you are just adding edge from v to u but remember one thing that this not a directed graph so you have to add edge from u to v.
Also it is mentioned that you have to give shortest path possible so along with if condition in
for(auto neighbour:adjlist[vertex]) loop you have to add else condition where you have to calculate the min of current distance of that neighbour if it is not -1 and distance to neighbour through this current vertex.
That is you have to use :
else{
distance[neighbour]=min(distance[neighbour],6+distance[vertex]);
}

I hope it will help you. :slight_smile: