two text cases are not passing what is the error IN MY CODE
RAT CHASES ITS CHEESE
In this question, the rat can move in all the 4 directions. So it is possible that it keeps on moving in a circle when it goes in recursion and visits the same node again and again.
So here you have to keep a check of nodes as well if the rat has visited them previously or not.
can you give an example so that i can visualize it more
Like your maze array is -
O O O O
O O O O
So there are chances that the rat can move in a circle in the first 4 cells.
It first goes right, down, left and up. So it is visiting the same node (the first one) again.