LeetCode 211 ·
Medium
Design Add and Search Words Data Structure
A dictionary supporting addWord and search, where search may contain "." matching any letter.
Try it
Step through the core mechanic. The simulator below runs the trie shape this problem is built on.
Walk the pattern
No dedicated step-through for this one yet. The shape is Trie — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.
The approach
Standard trie for add. For search, a "." branches into a DFS over all children at that depth; concrete letters follow the single matching link. Worst case fans out, but typical queries stay cheap.
| Aspect | Value |
|---|---|
| Pattern | Trie |
| Recognise it by | Trie search with a "." wildcard. |
| Time complexity | O(L) / O(Σ·L) |
| Space complexity | O(Σ·L) |
| Difficulty | Medium |
Who asks it
Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.