Design a text dictionary using a Trie.
Support the following operations:
addWord(word)
: Insert a lowercase English word.
search(pattern)
: Return
true
if any previously added word matches
pattern
.
The pattern may contain the wildcard character . which matches exactly one lowercase letter. (All other characters match themselves.)
You may implement a class with these two methods, or write functions that process a sequence of operations.