Node count
Warm-up · Trace the algorithm · about 5 min
Words are inserted into an empty trie one at a time. After each word, type how many nodes the trie has, not counting the root.
Example 1
Input:
{"commands":["insert tea","insert ten","insert to","insert inn"]}
Output:
8
Constraints
- The trace uses the input shown.
- Only new letters add nodes
Learn the idea first: Tries: insert, search, prefix, a visual lesson.
More Tries: insert, search, prefix problems
- Starts-with Warm-up
- Implement a trie Standard
- Longest common prefix Standard
- Trace a search Standard
- Word dictionary with wildcard Challenge