what is problem with my code and also tell how to print only one sol as Prateek bhaiya video gives all sol
#include
using namespace std;
bool issafe(char arr[][1001],int row,int col,int n,int m){
if(row<n && col<m && arr[row][col]!=‘X’){
return true;
}
return false;
}
bool maze(char arr[][1001],int row,int col,int sol[][1001],int n,int m){
if(row==n && col==m) {
sol[row][col] = 1;
return true;
}
if(issafe(arr,row,col,n,m)){
sol[row][col] = 1;
if(maze(arr,row,col+1,sol,n, m)){
return true;
}
if(maze(arr,row+1,col,sol,n,m)){
return true;
}
sol[row][col] = 0;
return false;
}
return false;
}
int main() {
int n,m;
cin>>n>>m;
char arr[1001][1001];
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
cin>>arr[i][j];
}
}
int row = 0;int col = 0;
int sol[1001][1001] = {0};
if( maze(arr,row,col,sol,n-1,m-1)) {
cout<<“path exist”<<endl;
for (int i = 0; i <= n; ++i)
{
for (int j = 0; j <= m; ++j)
{
cout<<sol[i][j]<<" ";
}
cout<<endl;
}
} else{
cout<<“path doesn’t exist”<<endl;
}
}