Sir, i failing in two test cases. please help me to find out my error

here is my code-> https://ide.codingblocks.com/s/460041

hello @chandreshmaurya

which question u r trying to solve?
the code that u shared is of rat in maze.
but u have raised the doubt for rat chases its cheese problem

it is same as the ‘Rat in maze’ ? that’s why, i copy that.

no its not , read the problem statement carefully.

here rat can move in all four directions

i read, and i thought that backtracking can solve that.

sir, can u send the any matrix, for which left and up’s concept is involving.

OXOOOO
OXOXOO
OXOOXO
OXXOXO
OOOOXO

1 Like

ok sir, i got, im going to try to solve this question.

sir, i tried. please help to find my mistake. code-> https://ide.codingblocks.com/s/460069

here becuase we can move in all four direction , it is possible that we reach to same position from where we started which will leads to infinite recusion as we will keep doing same thing again n again.

oox
oox
xxx
here example here -> if u go down then right then up and then left then u will arrive at location from where u started, and becuase of recusin we again started doing same steps agin, which will lead to infinite recusion

so to avoid it , return false if u see any visited cell.
check now->

1 Like

sir, i couldnt solve the question. please help in my code -> https://ide.codingblocks.com/s/460097

bro check my last response , already attached ur updated code

sir, i have one more doubt in line 62,63 & 64. ye puri matrix print kaise kar de rha rha hai, ise to hamne kewal bool ‘x’ me hi to store kraya hai .

ss

yaha pe hum print kar rahe hai na…, jab bhi hum is base case pe pahuchenge ye matrix print ho jayega

oohkay sir, i got it … thank you

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.