← Back to problems Solve on LeetCode →

Word Search II

LeetCode 212 • Hard • Tries

Input: board + words → find all words. Trie build + DFS on board. Example: board 2×2, words=["ab","ba"] → ["ab","ba"].

TimeO(m·n·4^L)
SpaceO(W)
path: found:
DFS path
Found
phase
path
found
Ready
Press Play. Build trie from words. DFS from each cell. When trie node is word end, add to result.