in the rat chasing the maze question, my code is giving incorrect output on 1 of the test cases https://ide.codingblocks.com/s/239245
Rat chases the maze(backtracking)
refer to this
the code you’ve sent is also giving wrong answer on test case 2 because there’s no difference in my code and the code you’ve sent
take all matrix size as 11*11
also
5 7
OXOOOOX
OXOXOXX
OXOXOOX
OOOXOXX
XXOXXXX
in this test case when there is no possible path
if(ans==false){
cout<<“NO PATH FOUND”;
}
is not encountered
i took all matrices as 11*11, still test case 2 is giving wrong answer. please make the required changes in my code
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.
this is a backtracking question. I’ve not studied dp till now. please tell the solution using backtracking approach
@pooja_narula the code you have sent initially here was correct,you have to just initialize your variables left, right,up,down with “false” else they may contain garbage value and cause problem. update this and your code will work fine.
thank you, it worked