Trie
Trie
·3 mins
Algorithm
Trie
String
Prefix
Bit-Manipulation
Building a Trie from nested dicts, counting on nodes, pairing it with DFS, and when a Trie is not actually needed
LeetCode 212: Word Search II
·2 mins
LeetCode
Hard
Trie
Backtracking
Matrix
LeetCode 212 note: build a Trie of all words, walk it during the grid DFS, remove words once found, and prune empty nodes
LeetCode 2416: Sum of Prefix Scores of Strings
·2 mins
LeetCode
Hard
Trie
String
Counting
LeetCode 2416 note: each Trie node counts the words passing through it, and a word’s answer is the sum of counts along its path
LeetCode 1178: Number of Valid Words for Each Puzzle
·3 mins
LeetCode
Hard
Bit-Manipulation
Hash-Map
Trie
LeetCode 1178 note: a word only matters by its set of letters, so count 26-bit masks and enumerate each puzzle’s submasks
LeetCode 1023: Camelcase Matching
·2 mins
LeetCode
Medium
Two-Pointers
String
Trie
LeetCode 1023 note: two pointers character by character; anything beyond the pattern must be lowercase
LeetCode 2781: Length of the Longest Valid Substring
·3 mins
LeetCode
Hard
Sliding-Window
Hash-Table
String
Trie
LeetCode 2781 note: forbidden words are at most 10 long, so each right end checks only the last 10 suffixes; on a match push the left end past it, using the shortest match (the rightmost start)
LeetCode 208: Implement Trie (Prefix Tree)
·2 mins
LeetCode
Medium
Hash-Table
String
Design
Trie
LeetCode 208 note: each node is a children dict plus an is_end flag; insert, search and startsWith all walk down character by character
LeetCode 14: Longest Common Prefix
·2 mins
LeetCode
Easy
Array
String
Trie
LeetCode 14 note: bound by the shortest string and check each position across all strings; the first mismatch gives the answer’s length