If hash maps are about looking up exact values, tries are about looking up prefixes. They're the data structure behind autocomplete, spell checkers, and any problem that cares about what a string starts with. This post breaks down what tries are, how they work under the hood, and why their performance characteristics make them irreplaceable for prefix-based problems.
What is a trie?
A trie (pronounced "try") is a tree where each path from root to node represents a prefix of some string. The root is empty. Each edge represents a character. Some everyday examples: