Snake and ladder game

what is my error here?

@chaman9
Your logic is correct but there is one mistake. You are intialising dist[node]=INT_MAX only for those node from while an edge originates. Since there is no node which originates from dest, thus it’s dist[dest] remain zero. So change line 21 to 25 from these lines
for(int i=0;i<=dest;i++)
{
dist[i]=INT_MAX;
}

your code will work

i didnt get you properly… and if i make change from line 21 to 25 the code isnt working either

please check

@chaman9
I have updated your code. please check it here

1 Like

thank you my doubt my cleared… but in line number 53 why you added board size as n+1??

@chaman9
check line 73, range of j can be upto n. So size of board must be greater than or equals to (n+1).

okay thanks a lot it has been solved

@chaman9
Please mark this doubt as resolved.

yeaah its done thanks