Multiple ways to traverse are being printed but i want to stop at one, used a global flag variable in alternate code so as to stop as soon as a figure out one way but one of the test cases failed. Please Assist.
Multiple ways to traverse are being printed
@HarmanHps you check both ways and if anyone exist do it but you have to do like this in order to generate only one
If destination is reached print the solution matrix .
Else .
a) Mark current cell in solution matrix as 1.
b) Move forward in the horizontal direction and recursively check if this move leads to a solution.
c) If the move chosen in the above step doesn’t lead to a solution then move down and check if this move leads to a solution.
d) If none of the above solutions works then unmark this cell as 0 (BACKTRACK) and return false
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.