code is showing timelimit and wrong answer in 2 and 6 testcase
Rat in the maze problem
In this code, you have to print only one path, so you have to maintain a visited array, initialised it to 1, and then check:
if(j+1<=M && !visited[i][j+1])
{
bool rightSuccess=ratmaze(maze,i,j+1,N,M);
if(rightSuccess==true)
{
return true;
}
}
Repeat this for down also, Try using this approach to prevent TLE, in your 6th testcase.
i am not able to understand.
I have edited your code, try to submit it now,
thanks for correcting