Rat In A Maze (to find rightmost path)

some test cases are not getting passed .please tell where the code is incorrect

#include
using namespace std;

bool ratInMaze(char maze[1000][1000],int sol[1000][1000],int i,int j,int m,int n){
// base case
if(i==m && j==n && maze[i][j]!=‘X’){
sol[m][n]=1;
// printing the sol array
for(int i=0;i<=m;i++){
for(int j=0;j<=n;j++){
cout<<sol[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}

// rec case

/// rat out of the grid
if(i>m || j>>n){
    return false;
}
// if obstacle comes
if(maze[i][j]=='X'){
    return false;
}

sol[i][j]=1;
bool path=0;
bool forwardSuccess=ratInMaze(maze,sol,i,j+1,m,n);
if(forwardSuccess){
    path=true;
}
if(!forwardSuccess){
    bool downSuccess=ratInMaze(maze,sol,i+1,j,m,n);
    if(downSuccess){
        path=true;
    }
    else{
        path=false;
    }
}


sol[i][j]=0;   // backtracking

return path;

}

int main() {
int m,n;
cin>>m>>n;
char maze[1000][1000];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>maze[i][j];
}
}
int sol[1000][1000]={0};

bool ans=ratInMaze(maze,sol,0,0,m-1,n-1);	

if(ans==false){
    cout<<"-1";
}

}

Hello @krikhi

In case of the rat is out the grid the if statement should be
if(i>m || i>n)
and Not
if(i>m || j>>n){

Here is the modified code

Let me know if you still need any help

Got it . Thanks a lot. It was just a typing mistake