Regarding test cases

Sir I am not passing 2 test cases. Can you tell why?

hello @punetha.anmol001

pls save ur code at cb ide and share its link with me

this problem is bit differnet from rat in maze problem.

here rat can move in all four directions. so from (i,j) u need to make four calls.

also because movement is allowed in all four direction , it is possible that u reach visited state more than once which will cause loop and the program will run ininfitely. so u need to keep the track of visited cells.if u reach to visited cell again then simply retunr false.
refer this->

Is it bcz rat can move left/top as well?

…

yes…
…
…

Got the solution sir, thanks

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.