WordDictionary
with a root node representing the start of the trie.addWord
by starting at the root and inserting each character of the word into the trie, creating new nodes as necessary. Mark the end of the word with a boolean flag.search
by starting at the root and traversing the trie according to the characters of the word.