StreamChecker class as follows:
StreamChecker(words): Constructor, init the data structure with the given words.
query(letter): returns true if and only if for some
k >= 1, the last
kcharacters queried (in order from oldest to newest, including this letter just queried) spell one of the words in the given list.
StreamChecker streamChecker = new StreamChecker(["cd","f","kl"]); // init the dictionary.
1 <= words.length <= 2000
1 <= words[i].length <= 2000
- Words will only consist of lowercase English letters.
- Queries will only consist of lowercase English letters.
- The number of queries is at most 40000.
from collections import defaultdict