Rat in a maze problem


one test case out of six , is not passing .

please tell the edge cases that i am not considering .

Note: please don’t edit the code . just comment .

Hi @sk3657860
Your code is failing for test case :
5 4
OXOO
OOOX
OOXO
XOOO
XXOO

Your output :
1 0 0 0
1 1 1 0
0 1 0 0
0 1 1 1
0 0 0 1

Correct output should be :
1 0 0 0
1 1 0 0
0 1 0 0
0 1 1 1
0 0 0 1

If your doubt is clear then mark it as resolved.

1 Like


same logic i have done with statically created array
its giving perfect.

can you please tell , why this is happening so

Hi @sk3657860
It does not matter whether you use static array or dynamic array in this question. The first code that you have shared was getting wrong answer for the test case because in that code at line number 35 that is sol[i][j]==0;
you are comparing sol[i][j] and 0 and there if you change == to = then all test cases will pass.

If your doubt is clear then mark it as resolved.

1 Like