Getting TLE and no output in 2 of the test cases.
Here is the code
Rat in a maze Backtrack
Hello @Kishan-Mishra-2464674013761441 ,
-
No Output is for the testcases like:
5 4
OXOO
XXOX
OOXO
XOOO
XXOO
Here, rat will stuck somewhere in between before reaching (n,m).
Your code is not dealing with it. -
It is giving TLE for an input of 1000 rows and 1000 columns.
Hope, this would help.
Give a like if you are satisfied.
I tried to handle the testcase you provided, and now i have added an if condition, that when the right and the down cell are blocked, it will backtrack to previous left cell, but if it is at the leftmost cell, it will print -1 and return. While running this and other similar test cases i am getting -1 as output but still on submitting i end up with no output and TLE.
For TLE, if i have to print a 2D matrix i will have to run 2 nested loops. Is there any way i can reduce complexity in this ?
Here is the code
I forget to tell you that the size of your matrix should be of [1001][1001].
You can refer to my code for removing bugs.
Click here.
It follows the same approch, but the producing output is little different.
Hope, this would help.
If you still have any doubt or you do not understand anything. Let me know.
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.