Description
Design a data structure that supports adding new words and finding if a string matches any previously added string. '.' can match any letter.
Examples
Input:
addWord("bad"), search("b.d")Output:
trueExplanation:
'.' matches 'a'.
Input:
input = ["bad","dad","mad"], arg2 = "pad"Output:
falseExplanation:
The target value does not exist in the given data structure.
Input:
input = ["bad","dad","mad"], arg2 = "b.d"Output:
trueExplanation:
The target value exists in the given data structure.
Input:
input = ["bad","dad","mad"], arg2 = ".ad"Output:
trueExplanation:
The target value exists in the given data structure.
Constraints
- •
1 ≤ word.length ≤ 25 - •
word consists of lowercase English letters. - •
search word may contain '.'.