Blind 75 Trie Questions
3 problems · Free practice
A trie shares work between words with the same prefix. Reaching a node proves that a prefix exists; an end marker proves that a complete word exists. Wildcards and board searches add branching, so the same structure can support both direct lookups and a search over several possible continuations.
Practice tries
Implement Trie (Prefix Tree)
MediumImplement insert(word), search(word), and startsWith(prefix) for lowercase words. Search requires a whole stored word; startsWith only requires a matching prefix.
Design Add and Search Words Data Structure
MediumSupport adding lowercase words and searching patterns where a dot matches exactly one arbitrary letter. A search succeeds if any stored word matches the entire pattern.
Word Search II
HardGiven a rectangular letter board and a list of distinct nonempty words, return those that can be traced using horizontal or vertical neighbors. A cell cannot be reused within one word.
What to focus on
- Keep the end-of-word flag separate from the presence of children.
- For wildcard search, track both the trie node and pattern position.
- Restore board cells after a search path and avoid reporting the same word twice.