Pattern Recognition Drill
Medium Tries
The Problem
Design a data structure that supports adding words and searching with '.' wildcards that match any character.
What approach would you use?
Think about it before scrolling down.
Insert normally. On search, DFS when encountering '.', trying all children. O(26^dots * L) worst case.
Group words by length, brute-force match on '.' — slower for large dictionaries.
Common Trap
The '.' wildcard means you must try ALL children at that level — can't just follow one path.