Snakes and ladders problem issue

what if the we arrive at a position where the jump is -ve and
after taking -ve jump we arrive at a position where a jump is +ve .so the final position will not be v=start+dice+board[start+dice] it will be board[v].are these cases considered in the code?

after answering the first please do answer this also,in this i have doubt regarding the size of the board array.the issue is:-----will it create any problem if we declare board as int board[37]={0}; and the grabage value at 38,39,40,41,42 are negative?i know the edges will be added in the graph which actually does not exist,but can it create wrong answer in some cases?if yes,please give a testcase in which it the wrong answer comes due to it.

in short i want to ask in the second question ----will it create any problem if we don’t initialise board values of 37 to 36+6=42 as zero?

Hey @Rj.25

  1. No there isn’t any case where a snake and ladder coincide just like it never happens in the actual game
  2. In case an edge outside board is being considered just ignore that edge and dont add it in the graph

If your doubt is resolved please close it

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.