🎉 All 30 days are live — the full DSA-30 course, from Big-O to System Design. See the roadmap →
Day 18 - TriesPractice QuestionsOverview

Trie Practice Questions

Eight problems that cover every trie shape: the plain set, the value-carrying map, the wildcard walk, the trie-guided grid DFS, and the bitwise trie. Once you’ve done these, “set of strings sharing prefixes” becomes a reflex.

The trie recognition signals:

  1. A set/dictionary of strings is queried for membership or prefixes repeatedly.
  2. You’re matching characters one at a time against many candidate words at once.
  3. The problem says “prefix,” “starts with,” “shortest root,” “autocomplete,” or “common prefix.”
  4. XOR maximization/pairs over integers → the bitwise trie.

If you see one of these, build a trie before you write anything else.

Easy

ProblemPatternStatus
Implement Trie (Prefix Tree)the core insert/search/startsWithAvailable

Medium

ProblemPatternStatus
Add & Search Word (wildcards)DFS walk with . matching any childAvailable
Replace Wordswalk to the shortest end-of-word rootAvailable
Map Sum Pairsstore values at nodes, sum a subtree/prefixAvailable
Longest Word in Dictionaryword buildable one char at a timeAvailable
Search Suggestions Systemautocomplete — top-k per prefixAvailable
Maximum XOR of Two Numbersbitwise trie, greedy MSB-firstAvailable

Hard

ProblemPatternStatus
Word Search IItrie + grid DFS with branch pruningAvailable

More Practice (Coming Soon)

ProblemPatternStatus
Concatenated Wordstrie + DP word-breakComing Soon
Stream of Characterssuffix trie, query reversedComing Soon
Palindrome Pairstrie of reversed wordsComing Soon
Word Squaresprefix-indexed backtrackingComing Soon
Design Search Autocomplete Systemtrie + ranking + live inputComing Soon
Maximum XOR With an Element From Arrayoffline queries + bitwise trieComing Soon
Count Pairs With XOR in a Rangebitwise trie countingComing Soon
Short Encoding of Wordstrie of reversed wordsComing Soon