My code is here
Rat in a maze all test cases not passing
@TheAlgo hey dhiraj
before making a recursive call first you have to check if you can make that particular cell of the matrix or not.
- Go Right
if(j+1<=n && maze[i][j+1]!=‘X’){
bool pathMila = ratinmaze(maze,sol,i,j+1,m,n);
if(pathMila==true){
return true;
}
}
/// 2. Go Down
if(i+1<=m && maze[i+1][j]!=‘X’){
bool pathMila = ratinmaze(maze,sol,i+1,j,m,n);
if(pathMila==true){
return true;
}
}
comment line 29 ,30 and 31
change in main function
bool ans=ratinmaze(maze,sol,0,0,m-1,n-1);
1 Like
itsvdone.Thank you,I have posted doubt for CB numbers , can you check it once?
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.