Problems

Design Add and Search Words

medium
medium
trie
backtracking
string
design

Execute add and search operations. In searches, . matches any single letter. Return search results as 1 for true and 0 for false, in order.

Constraints

  • 1 <= operations.length == words.length <= 10000
  • Search words contain lowercase letters or .

Follow-up

Why can wildcard-heavy searches become exponential in word length?

Examples

Example 1

Input: operations = ["add","add","add","search","search","search","search"], words = ["bad","dad","mad","pad","bad",".ad","b.."]
Output: [0,1,1,1]

Example 2

Input: operations = ["search"], words = ["."]
Output: [0]

Example 3

Input: operations = ["add","search"], words = ["a","."]
Output: [1]
🔒 5 hidden

Running will execute all 8 cases, including 5 hidden ones.