Implement a Prefix Tree (Trie)


Description

Implement a trie (prefix tree) with insert, search, and startsWith methods. Tries are used in many applications such as spell checking, autocompletion, and ip routing.

insert(word) Inserts the string word into the trie.

search(word) Returns True if the string word is in the trie (i.e., was inserted before), and False otherwise.

startsWith(prefix) Returns True if there is a previously inserted string word that has the prefix prefix, and False otherwise.

Part 2 of this problem (not shown on LeetCode) is to implement an autoComplete method.

Solution by YOUR_NAME_HERE or GITHUB_NAME

# INSERT CODE HERE


Comments

Comment on GitHub