BFS Snakes and Ladders problem

Problem : Snakes and Ladders: The Quickest Way Up
I have a bit different approach than the expected solution (
Let ‘s’ be the start of the ladder vertex and ‘e’ the end of ladder. They are replacing s with e for the previous 6 vertices of start vertex ‘s’. Same for snakes.

What I am doing:
adj[s] = adj[e]
i.e making the neighbours of the end vertex as neighbours of start vertex (as start and end are essentially
the same vertices as they have been connected by a ladder); which sounds logical to me. But I am not passing 3 testcases. Can someone please point out my mistake?
My full solution:
Rest of the things are same as solution, like building graph w/o snakes and ladders and applying BFS.

1 Like