Backtracking
101 / 170BacktrackingLesson 8 of 10About 48 min
Mark a cell as occupied, explore the neighbors, unmark it. The unmark is what makes it a search rather than a flood fill.
Searching for a path of length L from every cell of an m by n grid, with four directions available at each step. Give the time complexity in terms of the cell count and L, and the extra space beyond the grid.
for row in range(rows): for col in range(cols): if explore(row, col, 0): return TrueRead the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.