LeetCode 211 Design Add and Search Words - Why Naive Fails

The trap

Store words in a list. For search, check each word against the pattern.

With n words of average length m, each search checks all words: O(nm)O(n \cdot m).

For frequent searches, this becomes slow. Can you search more efficiently?