Comments

Wow Cool explanation !!

I got confused why ans can be >= d -1

Now got your intution of bfs