Data Structures, Explained Like You're Five: Tries
How does your phone suggest the rest of a word the moment you type "ca…"? Behind a lot of autocomplete is a trie (say it "try"): a tree where every branch is a letter, and words that start the same share the same branches.
The whole idea in one sentence
Store words letter by letter down a tree, so all the words beginning with "ca" live under one shared "ca" path — and finding every word with a given prefix is just walking to that spot.
Watch it happen
Hit Play. Watch "cat", "car", and "can" all reuse the same "c → a" path, splitting only at the last letter. The ringed nodes mark where a real word ends.
Why interviewers like it
A trie turns "find everything starting with these letters" into a quick walk down a few nodes, regardless of how many words you've stored. That makes it the go-to for autocomplete, spell-checkers, and prefix-matching problems. The trade-off worth mentioning: it spends extra memory on all those letter-nodes to buy that prefix speed.
Shared prefixes are the magic. Because "cat", "car", and "can" share one "ca" path, the trie can answer "what starts with ca?" by looking at a single branch.