Rat in a maze recursion

#include
using namespace std;
bool RatinMaze(char maze[][1000],int soln[][1000],int m,int n,int i,int j){
// base case
if(i==m && j==n){
soln[m][n]=1;
// prints
for(int i=0;i<=m;i++){
for(int j=0;j<=n;j++){
cout<<soln[i][j]<<" ";
}cout<<endl;
}
return true;
}
// recursive case
if(i>m or j>n){
return false;
}
if(maze[i][j]==‘X’){
return false;
}
soln[i][j]=1;
bool right=RatinMaze(maze,soln,m,n,i,j+1);
if(right)
return true;
bool down=RatinMaze(maze,soln,m,n,i+1,j);
if(down){
return true;

}
soln[i][j]=0;

return false;

}
int main() {
int m,n;cin>>m>>n;
char maze[1000][1000];int soln[1000][1000];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>maze[i][j];
}
}
bool ans=RatinMaze(maze,soln,m-1,n-1,0,0);
if(!ans){
cout<<"-1";
}
}

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.