I have written the exact same code as sir taught in video, but I am not getting right answer. all ements of solution array become 0. here is my code
#include
#include
using namespace std;
int sol[100][100]={0};
bool func(char arr[][100], int i, int j, int n, int m){
if( i==n-1 and j==m-1)
{
sol[i-1][j-1]=1;
for(int k=0;k<n;k++)
{
for(int l=0;l<m;l++)
{
cout<<sol[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}
sol[i][j]=1;
if(j+1<m and arr[i][j+1]!=‘x’)
{
bool isitgoodd=func(arr,i, j+1, n, m);
if(isitgoodd==true)
{return true;}
}
if(i+1<n and arr[i+1][j]!=‘x’)
{
bool isitgoodr=func(arr,i+1, j, n, m);
if(isitgoodr==true)
{return true;}
}
sol[i][j]=0;
return false;
}
int main() {
char maze[][100]={
“0000”,
“00xx”,
“0000”,
“xx00”,
};
func(maze,0, 0, 4, 4);
return 0;
}
output i got is
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0