LC 211
LeetCode 211 · Medium

Design Add and Search Words Data Structure

A dictionary supporting addWord and search, where search may contain "." matching any letter.

Trie → · High frequency · Solve on LeetCode →

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.

AspectValue
PatternTrie
Recognise it byTrie search with a "." wildcard.
Time complexityO(L) / O(Σ·L)
Space complexityO(Σ·L)
DifficultyMedium

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.