DSA question set · 160 questions
Trie DSA Practice Questions
Explore 160 DSA questions in Trie. Practice with DSAWiser’s code editor and visualizer.
TrieNode modelterminal flagsstructural invariantsCompressed edge slicesindex arithmeticWord Trieprefix traversalBinary/digit TrieSuffix Triedistinct substring nodesReversed-word Triesuffix existencesuffix countsaugmented traversaldictionary queriesBinary Triegreedy bit traversalcountslexicographical traversalstructural metricsDouble-array transition tracingSequential CAS simulationBurst Trie bucketscountingTernary search treepointer rotationPrefix-free codesexact weighted sumsprefix pass countsuniquenesswildcard branchingexactly-one-substitution searchwildcard backtrackingAugmented Trieprefix aggregate deltasterminal prefixestraversalsegmentationdynamic programmingstream suffix matchingoverlapping substring matchingSegment Triefolder ancestryString subsequence matchingPrefix and suffix filteringprefix matchingfrequency rankingdeletionnode pruningcommon substring matchingGrid backtracking prerequisiteRadix Triepath compressionPalindrome pairsdictionary matchingVowel normalizationXOR queriesoffline/tree/prefix techniquesoccurrence countsSubstring comparisondeduplicationdynamic stream matchingPalindromic prefixesstring algorithmsLOUDS representationdegree navigationSuffix LCEdirect string comparisongrid backtrackingmemoized segmentationenumerationprefix and suffix searchprefix candidatesbacktrackingAho-Corasickfailure linksoverlapping matchespalindrome pairsFolder Triesubtree signaturessimultaneous deletiondynamic autocompletePersistent binary Triepath copyingPersistent counted Trietree LCApath multiset subtraction
What’s in this set
The Trie collection contains 160 problems: 51 basic, 58 easy, 35 medium, 15 hard, 1 very hard. Choose a question at your current level, or follow the collection’s order below.
Topics in this collection include Trie, Node model, terminal flags, structural invariants, Compressed edge slices. Each question shows its own topics and difficulty so you can decide where to begin.
Practice with the code visualizer
- Open a question in the editor and read the statement, inputs, and expected output. Predict the result for a small example before writing code.
- Write a solution and run the examples. If a result differs from your prediction, reduce the input until you can follow each step.
- Step through your code in the visualizer. Use a breakpoint to inspect the state at a specific line, then compare it with your reasoning.
Questions in this set
160 totalOpen a question in the editor to read its statement and examples. Sign in to practice.
- TrieNode InitializationTrie · Node model · terminal flags · structural invariantsBasic
- Single Child Pointer Existence CheckTrie · Node model · terminal flags · structural invariantsBasic
- Direct Child Node AttachmentTrie · Node model · terminal flags · structural invariantsBasic
- Assign the End-of-Word FlagTrie · Node model · terminal flags · structural invariantsBasic
- Count Immediate ChildrenTrie · Node model · terminal flags · structural invariantsBasic
- Empty Trie Root VerificationTrie · Node model · terminal flags · structural invariantsBasic
- Character to Alphabet IndexTrie · Node model · terminal flags · structural invariantsBasic
- Alphabet Index to CharacterTrie · Node model · terminal flags · structural invariantsBasic
- Single-Character Word InsertionTrie · Node model · terminal flags · structural invariantsBasic
- Single-Character Word SearchTrie · Node model · terminal flags · structural invariantsBasic
- List Immediate Child CharactersTrie · Node model · terminal flags · structural invariantsBasic
- Check Leaf TrieNodeTrie · Node model · terminal flags · structural invariantsBasic
- Reset End-of-Word FlagTrie · Node model · terminal flags · structural invariantsBasic
- Child Existence Through an API HelperTrie · Node model · terminal flags · structural invariantsBasic
- Check If Trie Has Any Stored WordsTrie · Node model · terminal flags · structural invariantsBasic
- Exact Path Node Count for Single WordTrie · Node model · terminal flags · structural invariantsBasic
- Check Whether a Traversal Step Is AvailableTrie · Node model · terminal flags · structural invariantsBasic
- Find Depth of a Linear TrieTrie · Node model · terminal flags · structural invariantsBasic
- Direct Child Overwrite PreventionTrie · Node model · terminal flags · structural invariantsBasic
- Check Root End-of-WordTrie · Node model · terminal flags · structural invariantsBasic
- TrieNode with Prefix Pass Count InitializationTrie · Node model · terminal flags · structural invariantsBasic
- Increment Node Pass CountTrie · Node model · terminal flags · structural invariantsBasic
- Decrement Node Pass CountTrie · Node model · terminal flags · structural invariantsBasic
- TrieNode Storing Explicit Character ValueTrie · Node model · terminal flags · structural invariantsBasic
- Check If Any Child Has End-of-Word FlagTrie · Node model · terminal flags · structural invariantsBasic
- Common Prefix Length Between Two Words in TrieTrie · Node model · terminal flags · structural invariantsBasic
- Detect Branching NodeTrie · Node model · terminal flags · structural invariantsBasic
- Total Nodes for Two Disjoint WordsTrie · Node model · terminal flags · structural invariantsBasic
- Total Nodes for Identical WordsTrie · Node model · terminal flags · structural invariantsBasic
- Total Nodes for One Word Being Prefix of AnotherTrie · Node model · terminal flags · structural invariantsBasic
- Follow Exact PathTrie · Node model · terminal flags · structural invariantsBasic
- Get Terminal Node of PrefixTrie · Node model · terminal flags · structural invariantsBasic
- Count Words of Length OneTrie · Node model · terminal flags · structural invariantsBasic
- Find First Available Alphabetical ChildTrie · Node model · terminal flags · structural invariantsBasic
- Find Last Available Alphabetical ChildTrie · Node model · terminal flags · structural invariantsBasic
- Remove Single Child PointerTrie · Node model · terminal flags · structural invariantsBasic
- Can Delete Leaf Node SafelyTrie · Node model · terminal flags · structural invariantsBasic
- Clear All Children of a NodeTrie · Node model · terminal flags · structural invariantsBasic
- Unmark Word Without Removing NodesTrie · Node model · terminal flags · structural invariantsBasic
- Check Single Child PathTrie · Node model · terminal flags · structural invariantsBasic
- Binary TrieNode InitializationTrie · Node model · terminal flags · structural invariantsBasic
- Binary Trie Bit InsertionTrie · Node model · terminal flags · structural invariantsBasic
- Digit TrieNode Child VerificationTrie · Node model · terminal flags · structural invariantsBasic
- Case-Insensitive Trie Index MappingTrie · Node model · terminal flags · structural invariantsBasic
- Maximum Branching Factor of English Lowercase TrieTrie · Node model · terminal flags · structural invariantsBasic
- Count Total Words in a Linear ChainTrie · Node model · terminal flags · structural invariantsBasic
- Height of a Single-Node TrieTrie · Node model · terminal flags · structural invariantsBasic
- Verify an Exact Word at Its Terminal NodeTrie · Node model · terminal flags · structural invariantsBasic
- Count Marked Words Among ChildrenTrie · Node model · terminal flags · structural invariantsBasic
- Validate Single Word Insertion StateTrie · Node model · terminal flags · structural invariantsBasic
- Patricia Edge Slice ArithmeticTrie · Compressed edge slices · index arithmeticBasic
- Standard Word InsertionTrie · Word Trie · prefix traversal · terminal flagsEasy
- Standard Word SearchTrie · Word Trie · prefix traversal · terminal flagsEasy
- Prefix Search (startsWith)Trie · Word Trie · prefix traversal · terminal flagsEasy
- Total Words CountTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Words with Given PrefixTrie · Word Trie · prefix traversal · terminal flagsEasy
- Longest Common Prefix of an Array of StringsTrie · Word Trie · prefix traversal · terminal flagsEasy
- Longest Prefix Match of QueryTrie · Word Trie · prefix traversal · terminal flagsEasy
- Check If Any Word Is a Prefix of AnotherTrie · Word Trie · prefix traversal · terminal flagsEasy
- Total Characters Saved by Prefix CompressionTrie · Word Trie · prefix traversal · terminal flagsEasy
- Lexicographically Sorted Word ListingTrie · Word Trie · prefix traversal · terminal flagsEasy
- Reverse Lexicographically Sorted Word ListingTrie · Word Trie · prefix traversal · terminal flagsEasy
- Find Shortest Word Length in TrieTrie · Word Trie · prefix traversal · terminal flagsEasy
- Find Longest Word Length in TrieTrie · Word Trie · prefix traversal · terminal flagsEasy
- Maximum Depth of TrieTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Words of Exact Length KTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Words with Length at Most KTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Words with Length at Least KTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Total Leaf NodesTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Branching NodesTrie · Word Trie · prefix traversal · terminal flagsEasy
- Delete Single Standalone WordTrie · Word Trie · prefix traversal · terminal flagsEasy
- Delete Word Sharing PrefixTrie · Word Trie · prefix traversal · terminal flagsEasy
- Delete Word Having Shorter Prefix StoredTrie · Word Trie · prefix traversal · terminal flagsEasy
- Replace Word with RootTrie · Word Trie · prefix traversal · terminal flagsEasy
- Check If All Query Words ExistTrie · Word Trie · prefix traversal · terminal flagsEasy
- Check If Two Tries Are IdenticalTrie · Word Trie · prefix traversal · terminal flagsEasy
- Count Common Words Between Two TriesTrie · Word Trie · prefix traversal · terminal flagsEasy
- Merge Two TriesTrie · Word Trie · prefix traversal · terminal flagsEasy
- Check If Trie A Is a Subset of Trie BTrie · Word Trie · prefix traversal · terminal flagsEasy
- Find Difference CountTrie · Word Trie · prefix traversal · terminal flagsEasy
- Prefix Match with Trailing WildcardTrie · Word Trie · prefix traversal · terminal flagsEasy
- Autocomplete First SuggestionTrie · Word Trie · prefix traversal · terminal flagsEasy
- Check If Trie Contains Any Palindromic Word of Length 2 or 3Trie · Word Trie · prefix traversal · terminal flagsEasy
- Binary Trie Insert and SearchTrie · Binary/digit Trie · prefix traversalEasy
- Count Binary Strings with Given Bit PrefixTrie · Binary/digit Trie · prefix traversalEasy
- Maximum Value in 4-Bit Binary TrieTrie · Binary/digit Trie · prefix traversalEasy
- Minimum Value in 4-Bit Binary TrieTrie · Binary/digit Trie · prefix traversalEasy
- Digit Trie Contact SearchTrie · Binary/digit Trie · prefix traversalEasy
- Suffix Trie InsertionTrie · Suffix Trie · distinct substring nodesEasy
- Check If String Is a Suffix of Any WordTrie · Reversed-word Trie · suffix existenceEasy
- Find Words Ending with CharacterTrie · Reversed-word Trie · suffix countsEasy
- Count Words with Same Start and End CharacterTrie · Word Trie · prefix traversal · terminal flagsEasy
- Distinct Prefixes CountTrie · Word Trie · prefix traversal · terminal flagsEasy
- Most Frequent Starting CharacterTrie · Word Trie · prefix traversal · terminal flagsEasy
- Check If Trie Has Only Single-Path WordsTrie · Word Trie · prefix traversal · terminal flagsEasy
- Pre-Order Trie Traversal SerializationTrie · Word Trie · prefix traversal · terminal flagsEasy
- Maximum Word Prefix OverlapTrie · Word Trie · prefix traversal · terminal flagsEasy
- Comprehensive Trie Summary StatisticsTrie · Word Trie · prefix traversal · terminal flagsEasy
- Autocomplete All Words Matching PrefixTrie · Word Trie · augmented traversal · dictionary queriesEasy
- Replace Words in Sentence by RootTrie · Word Trie · augmented traversal · dictionary queriesEasy
- Longest Common Bit Prefix of Fixed-Length Binary StringsTrie · Binary Trie · greedy bit traversal · countsEasy
- Lexicographically K-th Smallest WordTrie · Word Trie · lexicographical traversalEasy
- Count Words with Given Suffix Using Reversed TrieTrie · Reversed-word Trie · suffix countsEasy
- Maximum Branching Factor and Average Word DepthTrie · Word Trie · structural metricsEasy
- Double-Array Trie (DAT) State Transition and ValidationTrie · Double-array transition tracingEasy
- Sequential Compare-and-Swap SimulationTrie · Sequential CAS simulationEasy
- Burst Trie Bucket Partition CountsTrie · Burst Trie buckets · countingEasy
- Ternary Search Tree: Single Left Rotation LinksTrie · Ternary search tree · pointer rotationEasy
- Prefix-Free Code Length and Kraft EqualityTrie · Prefix-free codes · exact weighted sumsEasy
- Shortest Unique Prefix for a Single QueryTrie · Word Trie · prefix pass counts · uniquenessMedium
- Exact Single Wildcard MatchTrie · Word Trie · wildcard branchingMedium
- Word Distance by One Character SubstitutionTrie · Word Trie · exactly-one-substitution searchMedium
- Multi-Wildcard Pattern SearchTrie · Word Trie · wildcard backtrackingMedium
- Map Sum Pairs (Prefix Value Aggregation)Trie · Augmented Trie · prefix aggregate deltasMedium
- Shortest Unique Prefix for Every WordTrie · Word Trie · prefix pass counts · uniquenessMedium
- Maximum XOR of Two Numbers in an ArrayTrie · Binary Trie · greedy bit traversal · countsMedium
- Maximum XOR with Query ValueTrie · Binary Trie · greedy bit traversal · countsMedium
- Minimum XOR Pair in an ArrayTrie · Binary Trie · greedy bit traversal · countsMedium
- Count Numbers with XOR Less Than KTrie · Binary Trie · greedy bit traversal · countsMedium
- Longest Word in Dictionary Built One Letter at a TimeTrie · Word Trie · terminal prefixes · traversalMedium
- Word Break Segmentation Using TrieTrie · Word Trie · segmentation · dynamic programmingMedium
- Stream of Characters (Suffix Query in Stream)Trie · Reversed-word Trie · stream suffix matchingMedium
- Count Distinct Substrings via Suffix TrieTrie · Suffix Trie · distinct substring nodesMedium
- Index Pairs of a StringTrie · Word Trie · overlapping substring matchingMedium
- Magic Dictionary (One-Edit Search)Trie · Word Trie · exactly-one-substitution searchMedium
- Remove Sub-Folders from FilesystemTrie · Segment Trie · folder ancestryMedium
- Camelcase MatchingTrie · String subsequence matchingMedium
- Words with Exact Prefix and SuffixTrie · Prefix and suffix filteringMedium
- Top-K Frequent Words with PrefixTrie · Word Trie · prefix matching · frequency rankingMedium
- Recursive Bottom-Up Node Pruning on DeletionTrie · Word Trie · deletion · node pruningMedium
- Concatenated Word CheckTrie · Word Trie · segmentation · dynamic programmingMedium
- Longest Common Substring of Two Strings via Suffix TrieTrie · Suffix Trie · common substring matchingMedium
- Word Search with Four-Direction AdjacencyTrie · Grid backtracking prerequisiteMedium
- Radix / Compressed Trie Node CountTrie · Radix Trie · path compressionMedium
- Palindrome Pair DetectionTrie · Palindrome pairs · dictionary matchingMedium
- Spell Checker with Vowel Error TolerationTrie · Vowel normalization · dictionary matchingMedium
- Maximum XOR SubarrayTrie · Binary Trie · XOR queries · offline/tree/prefix techniquesMedium
- Maximum XOR Across Two ArraysTrie · Binary Trie · XOR queries · offline/tree/prefix techniquesMedium
- Longest Duplicate Substring Length via Suffix TrieTrie · Suffix Trie · occurrence countsMedium
- Count Distinct Echo SubstringsTrie · Substring comparison · deduplicationMedium
- Stream Suffix Substring Matching with Dynamic VocabularyTrie · Reversed-word Trie · dynamic stream matchingMedium
- Shortest Palindrome via Prefix Trie Suffix SymmetryTrie · Palindromic prefixes · string algorithmsMedium
- LOUDS Degree-Block NavigationTrie · LOUDS representation · degree navigationMedium
- Longest Common Extension Queries on Two StringsTrie · Suffix LCE · direct string comparisonMedium
- Word Search II (Find All Dictionary Words on a 2D Board)Trie · Word Trie · grid backtrackingHard
- Word Break II (Reconstruct All Valid Sentences)Trie · Word Trie · memoized segmentation · enumerationHard
- Prefix and Suffix Search (WordFilter Engine)Trie · Word Trie · prefix and suffix searchHard
- Word Squares ConstructionTrie · Word Trie · prefix candidates · backtrackingHard
- Multi-Word Aho-Corasick String MatchingTrie · Aho-Corasick · failure links · overlapping matchesHard
- Maximum XOR With an Element From Array Under Value ConstraintTrie · Binary Trie · XOR queries · offline/tree/prefix techniquesHard
- Count Pairs with XOR in a Given Range [low, high]Trie · Binary Trie · XOR queries · offline/tree/prefix techniquesHard
- Maximum Genetic Difference QueryTrie · Binary Trie · XOR queries · offline/tree/prefix techniquesHard
- Palindrome Pairs (All Distinct Index Pairs)Trie · Reversed-word Trie · palindrome pairsHard
- Concatenated Words in a Large DictionaryTrie · Word Trie · segmentation · dynamic programmingHard
- Delete Duplicate Folders in System via Subtree HashingTrie · Folder Trie · subtree signatures · simultaneous deletionHard
- Search Autocomplete System with Frequency RankingTrie · Word Trie · dynamic autocomplete · frequency rankingHard
- Maximum Subarray XOR with Length At Most KTrie · Binary Trie · XOR queries · offline/tree/prefix techniquesHard
- K-th Smallest Subarray XORTrie · Binary Trie · XOR queries · offline/tree/prefix techniquesHard
- Fully Persistent Binary Trie (Versioned Path-Copying)Trie · Persistent binary Trie · path copyingHard
- Persistent Binary Trie Path XOR on a TreeTrie · Persistent counted Trie · tree LCA · path multiset subtractionVery hard