Stream Of Characters
medium
Implement the StreamChecker class as follows: 1. StreamChecker(words): Constructor, init the data structure with the given words. 2. query(letter): returns true if and only if for some k >= 1, the last k characters queried (in order from oldest to newest, including this letter just queried) spell one of the words in the given list.
Constraints
1. Words will only consist of lowercase English letters. 2. Queries will only consist of lowercase English letters
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
3
cd
f
kl
12
a
b
c
d
e
f
g
h
i
j
k
l
Sample Output
false
false
false
true
false
true
false
false
false
false
false
true