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.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1. Words will only consist of lowercase English letters.
2. Queries will only consist of lowercase English letters

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
3
cd
f
kl
12
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
Previous
Longest Word In Dictionary
Next
Count Pairs With Xor In A Range

Related Questions