Algo++ : Rat in a maze problem

All test cases are running except test case 1 ,it is showing time limit exceeded .
please suggest some corrections that will make it more efficient .

Plz send your code by saving on ide only.

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;
}
}

it is still showing TLE .please help code link : https://ide.codingblocks.com/s/100777


I have modified your code as i discussed with you. Plz refer to it.