Try every cell as a start and DFS in 4 directions matching characters.
Backtracking DFS:
word[i], mark visited (temporary overwrite), explore neighbors for i+1, then restore.A valid path corresponds to a simple path in the grid; backtracking explores all possibilities without revisiting cells.
Try every cell as a start and DFS in 4 directions matching characters.
Backtracking DFS:
word[i], mark visited (temporary overwrite), explore neighbors for i+1, then restore.A valid path corresponds to a simple path in the grid; backtracking explores all possibilities without revisiting cells.