Design a data structure supporting addWord and search. The search can contain '.' which matches any single character.
Trie + DFS. When we encounter '.', try all children recursively.
💡 Pro tip: Understand this problem deeply — don't just memorize the code. Try explaining the approach out loud as if teaching a friend. If you can explain it simply, you truly understand it!
wd.search('pad')
False
wd.search('bad')
True
wd.search('.ad')
True
wd.search('b..')
True