//rat in a maze test case 3 and 4 cant be passed

//kindly tell me what the problem is with this code

#include
using namespace std;

bool rat_in_maze(char maze[][1000],int soln[][1000],int i,int j,int m,int n){
if(i==m and j==n){
soln[m][n]=1;

    for(int h=0;h<=m;h++){
        for(int p=0;p<=n;p++){
            cout<<soln[h][p]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;

    return true;
}

if(i>m or j>n){
    return 0;
}

if(maze[i][j]=='X'){
    return 0;
}
soln[i][j]=1;

bool right= rat_in_maze(maze,soln,i,j+1,m,n);

if(right){
        soln[i][j]=0;
        return true;
}
bool down= rat_in_maze(maze,soln,i+1,j,m,n);
if(down){
        soln[i][j]=0;
        return true;
}

//soln[i][j]=0;


return 0;

}

int main(){
char maze[1000][1000];

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

rat_in_maze(maze,soln,0,0,m-1,n-1);
return 0;
}

code logic looks correct
can you share the link of your code
so that i can check and run your code

save your code at ide.codingblocks.com and share the url generated

if solution doesn’t exists then you have to print -1
this case you forgot

I have corrected your code and now it is passing all testcases

Modified Code

if you have any doubt feel free to ask
else
now i am marking your doubt as resolved kindly give feedback

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.