Maze Question Backtracking Doubt

My code :

  • this works fine but i have a doubt that
  • we need to marks the point as 0 while backtracking then why did we include the
    sol[x][y] = 0 in line 80.
    should’nt we write that line once in line 70 and once in line 76

hi @dar_angel007

if solveMazeUtil(maze, x + 1, y, sol) == true
then our maze is solved and we have print the solution
now in backtrack there is no need to put sol[x][y]=0 as we are returning true

we need to put sol[i][j]=0 when maze is not solve and we have to try again for different solution
so it should come on line 80

i hope this help
if you have more doubts regarding this feel free to ask

if doubt is resolved Please mark it as resolved

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.