Back to problems

Add and Search Word

Low-Level Design · Hard

Construct a data structure that can hold a collection of strings and later respond to membership queries. A query string may include the special character ., which acts as a placeholder that matches exactly one arbitrary character. Implement the WordDictionary class: WordDictionary() initializes an empty dictionary object. void addWord(String word) inserts the given word into the collection. boolean search(String word) returns true if the collection contains at least one…

Checking your access…