Shortest path using bfs

sample test case passed but got an error message during submitting a code


I have fixed the run error which was arising due to index out of bound error.
Try to fix your solution further, since it is a pretty standard problem, I strongly recommend you to solve it by yourself. If you face any doubt you can reply to this thread.

I changed initial value of parent array is INT_MAX and tried other things but i am getting wrong answer

can i know where i am doing wrong

please reply i am facing doubt

@abhinandankainth1999 I found the errors in the very first code you submitted.
Please increase the size of your graph to bool graph[n+1][n+1];
Increase the size of visited to visited[n+1]
and add this line after line 65.
q.push(i);// you haven’t been pushing the new elements into your queue so bfs is not running correctly.