Failing in some test cases
@Sunkumsav hey
You just simply need to maintain a visited path also, and before moving down or to right, just check the condition as per few lines of code.
if(visited[i][j])
{
return false;
}
solution[i][j]=1;
visited[i][j]=1;
if(j+1<=M && !visited[i][j+1])
{
bool rightSuccess=ratmaze(maze,i,j+1,N,M);
if(rightSuccess==true)
{
return true;
}
}
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.