Rat in maze, extra output


how to print only first output, as asked in question ?

Hey your code is almost correct but it is printing all possible solution. This is because you are moving in both right and down direction even if your rightSuccess returns true. You need not to go for downSuccess if your rightSuccess return true (find a way to reach N,M). So just add a if condition i.e if(rightSuccess){ return true; } after line no. 31
your code will work fine.

1 Like

@shrm.abhishek.kmr thank you :smiley: