Only 1 test case is failing

please check my code as only 1 test case is failing.

there is one problem with your approach
suppose if at some cell in the middle of board we are not able to move forward
so we return false from that cell but from the previous cell we are returning true which is wrong

your code will give wrong ans for the input
5 7
OXOOOOX
OXOXOXX
OXOXOOX
OOOXOXX
XXOXXXX

look at Modified Code below

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like :heart:: and don’t forgot to mark doubt as resolved :grinning:

but in your example, there seems to be no path for the rat to reach the finish.

yes in this case you have to print Invalid path
but your code is not printing anyting
because neither you reach at end
nor you return false to main