Please check
Rat chases cheese
i have done some changes you can check
1 you also have to add two conditons i<0 and j<0
if (i>=N or j>=M or i<0 or j<0){
return false;
}
- this condition is also require otherwise it keep moving left right left right …
if(soln[i][j]==1)return false;
Modified code
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.