Help needed with this graph problem

Hello, i just learned graph and i saw this beautiful problem with tag bfs.I know how bfs works but cant figure out how to do this bfs.I need help with this.Your solution link with some description will do.Thanks(link)

UPDATE–> Sir,i tried implementing myself but i think i missed something can you take a look at my solution

See my code , I have written comments in it.


Lovely code sir

your welcome :slight_smile: and don’t call me sir bro, I’m still an UG student.


Update ans: Here is the link of my submission and I have made some changes for which I have written comments.

If you have further doubts, then don’t hesitate to ask. I will explain in more detail.

1 Like