Add and Search Words Data Structure
Design a data structure called WordDictionary that stores lowercase words and supports wildcard searches.
Implement the behavior for:
WordDictionary(): Initializes an empty dictionary.addWord(word): Addswordto the dictionary.search(word): Returnstrueif any added word matchesword. The.character can match any single lowercase letter.
operations = [ WordDictionary addWord bad addWord dad addWord mad search pad search bad search .ad search b.. ]
false true true true
1 <= word.length <= 25for added words and search patternswordinaddWordconsists of lowercase English letterswordinsearchconsists of lowercase English letters and.- At most
10^4calls will be made toaddWordandsearch