Rat chases it's cheese

How to handle the case when it can go up or left?
I have commented out the part because it gives segmentation fault.

Hey @div_yanshu07
Just maintain a visited array as well so that u don’t revisit the visited state

check this https://ide.codingblocks.com/s/393823

Okay, I understood only one doubt. Since we are having only one unique path that is why while backtracking we are not marking it as 0 right?

Our visited matrix*…

Yes correct @div_yanshu07

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.