Design Add and Search Words (Wildcards)

Medium · Trie · about 25 minutes

Asked at Meta, Amazon, Google.

Design a WordDictionary with addWord(word) and search(word), where the searched word may contain '.' characters that match any single letter. search returns true if any added word matches.

Related guides