Interview Bootcamp
0% completed
Solution: Design Add and Search Words Data Structure
Problem Statement
Design a data structure that supports the addition of new words and the ability to check if a string matches any previously added word.
Implement the Solution class:
Solution()Initializes the object.void addWord(word)Insertswordinto the data structure, making it available for future searches.bool search(word)Checks if there is any word in the data structure that matchesword. The method returnstrueif such a match exists, otherwise returnsfalse.
Note: In the search query word, the character `'.'
.....
.....
.....
Like the course? Get enrolled and start learning!
J
Jimmy
· 2 years ago
For example #1 in the Justification section, "banana" does not match the "....." pattern.
For example #3 in the Expected Output section, the expected output for ["h...o"] should be 1, not 0.
Show 1 reply