Some of the test cases going wrong

@Mudit809
check condition in line no. 18, it should be if(i>n || j>m)

how can i print -1 if there is no path for rat to reach to the end?

@Mudit809
change line 50 to
if(ratInMaze(input,output,n-1,m-1,0,0)==false){
cout<<-1<<endl;
}

@Mudit809
As I can see you got 100 points, please mark this doubt as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.