Word Search II
Return all words that can be formed by adjacent letters on the board.
Examples
Input: [["oaan","etae","ihkr","iflv"],["oath","pea","eat","rain"]]
Output: ["eat","oath"]
Input: [["ab","cd"],["ab","cb","ad","bd"]]
Output: ["ab"]
Hints
Use DFS to explore all possible paths from each cell, checking against the trie for valid word completions.
Optimize by pruning paths where the current trie node has no children, reducing unnecessary computations.
Implement backtracking with bitmasking or a visited matrix to efficiently track used cells and avoid revisiting them in the same path.
Related Problems
Word Search II
Return all words that can be formed by adjacent letters on the board.