visited
with the same dimensions as the maze to keep track of visited cells.dfs
function that takes the current position and the maze as arguments.true
.false
.dfs
function with the new position (just before the wall).true
, propagate this result back up, indicating a successful path.false
.