The algorithm: For each cell in the grid: - If cell matches word[], start DFS from that cell DFS(row, col, index): - If index equals word length, return true - If out of bounds or cell doesn't match or visited, return false - Mark cell as visited (or change to a placeholder) - Try all directions recursively - Unmark cell (backtrack) - Return true if any direction succeeded
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/backtracking/word-search-solution
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████████████████████████████████████████████████████████████████████████████████