Please Explain the test cases
BFS - Shortest Path
@Bansaljatin05,
1st graph:
1-2
/ 4
3
Starting from 1, distance[2]=6, distance[3]=6, distance[4]=-1(not reachable)
2nd graph,
2 - 3 1
Starting from 2, distance[1]=-1, distance[3]=6
1 Like
Hi @abhijeet.srivastava6499,
in ur addedge function , add dis adjList[v].push_back(u); since given graphs are bidirectional. Ur code will pass d testcases.
Hope dis resolves ur doubt.
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.