Word Search
Backtrack through adjacent grid cells, match one character per depth, and restore visited cells after failure.
Core idea
Try every matching start cell, then recurse to adjacent cells for successive characters. Mark a cell while it is on the path and restore it when the branch returns.
Read the visualization
The board distinguishes the current path, rejected candidates, and restored cells. The character index shows exactly which word position each recursive depth must match.
Try this grid cell as the first character of the target word.
Complexity and tradeoffs
Time: O(RC × 4^L). Space: O(L). Character checks and no-revisit rules prune the worst-case branching for word length L.
Where it fits
Word Search demonstrates path-local visited state. Multiple-word searches often replace repeated backtracking with a trie that prunes many prefixes together.