Help needed in debugging.Rat in Maze Problem

My Code is showing wrong output for sample test case could you please tell me where i am going wrong?

hi @utkarshvashisth94 there is no need of so many functions as they will just overcomplicate the implementation, it can be done using one simple function, please refer to this code and let me know if you have any confusion

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.