my code is not able to display one it is actually displaying all the ways in one array, please help me to get the desired output for the question, and ALSO ANSWER THE DOUBT SOONER PLEASE, DON’T PROCRASTINATE
Rat in a maze/////////
Neerav, I have changed the size of array in your code, due to which your code is passing 4 test cases out of 6, now for 1 test case which is showing TLE, you need to maintain a visited array as
int visited[1001][1001]
and while you are initializing solution matrix as 1, initialise this also as 1, and then before you go downwards or rightwards, simply check that,
if(j+1<=M && !visited[i][j+1])
{
bool rightSuccess=ratmaze(maze,i,j+1,N,M);
if(rightSuccess==true)
{
return true;
}
}
Same you have to follow for downwards too
Refer to the code, I have changed the size too