The path from the root to each node is a prefix is a word in the dictionary.

因此也叫前缀树。

常考问题:怎么设计一个dictionary?

TC:

n - # of words

m - average length of the string/ word

worst case guarantee O(m)

Implementation

做两道题练练手

Implement Trie

Implement Trie II

Trie的题目: