Problems

Implement Trie

medium
medium
trie
string
design

Execute parallel operations and words. Operations are insert, search, or startsWith; return 1 for true and 0 for false for query operations in order.

Constraints

  • 1 <= operations.length == words.length <= 10000
  • Words contain lowercase English letters

Follow-up

How do array children compare with hash-map children?

Examples

Example 1

Input: operations = ["insert","search","search","startsWith","insert","search"], words = ["apple","apple","app","app","app","app"]
Output: [1,0,1,1]

Example 2

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

Example 3

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

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