How would a hash set, a sorted list, and a trie answer exact membership or prefix "sto"?
Why does reaching sto fail to prove that sto was inserted?
1 / 6
Implement Trie (Prefix Tree) — predict before coding
A path records a prefix; an end marker records membership of a complete word. Keeping those two facts separate makes insertion, exact search, and prefix search small operations with different stopping conditions.
Decision: After Insert("apple"), what are Search("app"), StartsWith("app"), and Search("apple")? What changes after Insert("app")?
2 / 6
Design Add and Search Words Data Structure — predict before coding
A dot means exactly one character, not any-length text. Searching is a DFS over (trie node, pattern position); a literal has one possible edge and a wildcard may branch.
Decision: After adding bad, dad, and mad, which of .ad, b.., .., and b... match? Why is dot not equivalent to a regular-expression star?
3 / 6
Word Search II — predict before coding
Combine two pruning rules: a board path cannot reuse cells, and its letters must remain a dictionary prefix. The trie shares work among words; it does not replace the board visited state.
Decision: With dictionary ["a","ab"] and adjacent board cells a,b, why may you clear the terminal word at a but not delete the entire a branch?
4 / 6
Replace Words — predict before coding
The shortest matching root is the first terminal encountered while walking a sentence word. Unlike longest-prefix routing, continuing past that terminal would solve the wrong problem.
Decision: With roots ["cat","c","cattle"], what replaces "cattle"? Does dictionary insertion order affect the result?
5 / 6
Change one stopping rule
Roots are ["an","ant"]. Compare shortest-root and longest-root replacement of "antler".
Then explain why finding word "an" during board search cannot use either replacement rule blindly.
6 / 6
←/→ or click edges to navigate · ? help · N notes · F fullscreen