We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
A medium trie problem, graded against 6 test cases (3 of them hidden).
A prefix tree for fast string lookup by shared prefix.
Reach for it when you see: Many words, repeated prefix queries, autocomplete, or word-search over a grid.
More Trieproblems →Each node stores a map of children (letter -> node) and an end-of-word flag. Insert creates nodes as needed. Search follows the path and checks the end flag. StartsWith follows the path without checking the end flag.
The full reference solution in every supported language stays in the editor above - reveal it there once you have had a real attempt.
These apply to the pattern as a whole, not just this problem.