Pattern Recognition Drill
Medium Tries
The Problem
Implement a trie with insert, search, and startsWith methods.
What approach would you use?
Think about it before scrolling down.
Build tree of characters. Insert walks/creates nodes. Search checks end flag. startsWith just walks. O(L) per op.
Store all words in a set (search is O(L)), but startsWith requires scanning all words.
Common Trap
Don't forget the `end_of_word` boolean flag — search and startsWith differ only by this check.