backtracking will happen only when left success and right success both is false and then we should have to make soln[i][j]=0
According to me code should be like
bool leftSuccess=ratInMaze(maze,soln,i,j+1,m,n);
bool rightSuccess=ratInMaze(maze,soln,i+1,j,m,n);
if(leftSuccess or rightSuccess)
{
return true;
}
else{
soln[i][j]=0;
return false;
}