BFS Shortest path Problem

Can you please check why my code is giving WA?

code :

@Rhinorox see the output of the second test case in the sample i/o, the order of output is not correct

How to deal with that?

@Rhinorox do a dry run of your code

Using Maps i can store orderly, thanks

1 Like