Design a data stream checker that returns whether any suffix of the current stream matches one of the inserted words. Pattern focus: Trie Node Structure. Reversing the dictionary words turns suffix checks into prefix traversal on the trie.
words = dictionary words, queries = streamed characters in order
boolean results after each streamed character
Example 1:
Input:
words = ["cd","f","kl"] queries = ["a","b","c","d","e","f","g","h","i","j","k","l"]
Output:
[false,false,false,true,false,true,false,false,false,false,false,true]
Explanation:
A suffix match appears when the stream ends with cd, f, or kl.
Example 2:
Input:
words = ["a"] queries = ["a"]
Output:
[true]
Explanation:
A one-letter dictionary word matches immediately.
Example 3:
Input:
words = ["ab","ba","aa"] queries = ["a","b","a","a"]
Output:
[false,true,true,true]
Explanation:
Different suffixes can become valid as the stream grows.