Given a character board and a dictionary, return every word that can be formed by moving horizontally or vertically between adjacent cells. Pattern focus: Word Search with Trie (Multi-Word DFS). This variant emphasizes clean trie traversal with deterministic output ordering.
board = character grid, words = dictionary words
all matched words in lexicographic order
Example 1:
Input:
board = [["s","e","a"],["t","r","e"],["n","o","w"]] words = ["sea","sear","row","stone"]
Output:
["row","sea"]
Explanation:
Only the words that can be traced with adjacent moves are returned.
Example 2:
Input:
board = [["a"]] words = ["b"]
Output:
[]
Explanation:
A non-matching single-cell grid returns no result.
Example 3:
Input:
board = [["c","a","t"],["a","r","e"],["d","o","g"]] words = ["cat","car","dog","cog"]
Output:
["car","cat","dog"]
Explanation:
Multiple valid words may be discovered from the same board.