In my previous story on Backtracking, we walked through a simple question where given a maze, determine whether there is a path from point A to point B. The given constraints are the walls in the maze. Today, I want to go through a slightly more complicated question. The question description can be found here: Leetcode 79 . Similar to question in my previous story, the given 2D character array here can be seen as a maze. But different than the previous question, since from 1 cell, there are 4 potential neighbors to visit. If we don’t keep track of if a cell has been visited, we will get into an infinite circular path.