What is a trie and what problems does it solve?
LeetCode Patterns Flashcards: Tries, Design Problems, LRU Cache, Time Complexity
Аудио-карточка · 0:30Nortren·
What is a trie and what problems does it solve?
0:30
A trie, also called a prefix tree, is a tree data structure where each node represents a character and paths from the root represent strings or prefixes. Each node has up to 26 children for lowercase English letters. A boolean flag marks nodes where a complete word ends. Tries support insertion, search, and prefix matching all in O of m time where m is the word length, independent of how many words are stored. They solve autocomplete, spell checking, word search in grids, finding all words with a common prefix, and the word break problem.
neetcode.io