Test case 0,1 and 3 not getting cleared

#include
using namespace std;
int sol[100][100]={0};
bool ratinmaze(char a[][100],int i,int j,int n,int m){

//base case
if(i==n-1 && j==m-1){
sol[i][j]=1;
for(int k=0;k<n;k++){
for(int l=0;l<m;l++){
cout<<sol[k][l]<<" ";
}

cout<<endl;
}
cout<<endl;
return true;

}

//recursive case
sol[i][j] = 1;
if(j + 1 < m && a[i][j+1] != ‘X’){
bool sok= ratinmaze(a,i,j+1,n,m);
if(sok==true){
return true;
}

}
if(i+1 < n && a[i+1][j] != ‘X’){
bool val= ratinmaze(a,i+1,j,n,m);
if(val==true){
return true;
}
}
sol[i][j]=0;

return false;

}
int main() {

char ans[100][100];
int n,m;
cin>>n;
cin>>m;
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		cin>>ans[i][j];
	}
}

bool k=ratinmaze(ans,0,0,n,m);
if(k==false){
cout<<-1<<endl;
}

}

hi @uvanshika
updated and commented

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.