tle is coming in the three cases
Rat in a maze problem
Pls share your code by saving on ide so that I could check it…
There is my code for rat in maze
Here you need to maintain a visited array as int visited[1000][1000] and do the following as
sol[i][j]=1;
visited[i][j]=1;
if(j+1<=m && !visited[i][j+1])
{
bool rightSuccess=ratinmaze(arr,i,j+1,m,n)
if(rightSuccess==true)
{
return true;
}
}
Similarly do for downSuccess as well,.This approach need to be followed as 3 wrong answers are coming…
can you tell me what is the mistake in my code??
It is given that you are supposed to print rightmost path only… In some test cases, your code is not printing the rightmost path… So for that you need to maintain the visited path array and then you need to implement the approach I have told you…