Design Add and Search Words Data Structure

Design a data structure that stores words and searches them with wildcards.

  • addWord(word) inserts one lowercase word.
  • search(word) returns true when a stored word matches the whole pattern.
  • In a search pattern, . matches any single lowercase English letter.
Examples
Input: [["WordDictionary","addWord","addWord","search","search","search"],[[],["bad"],["dad"],["pad"],["bad"],[".ad"]]]
Output: [null,null,null,false,true,true]
Hints

Design Add and Search Words Data Structure

Design a data structure that stores words and searches them with wildcards.