Backtracking is a method to solve problems using recursion, by trying to find different solutions by erasing or forgetting about a solution if it turns out to be invalid.
The idea is we start at a grid position, then to make a move we check if all four directions give us a valid path. We can leave markers behind us to show that we’ve been at that position already.1