Description
Given an string array words and an string array queries, design a StreamChecker that checks if the last k characters queried spell any word from a dictionary. Return the result as an array.
Examples
Input:
words = ["cd","f","kl"], queries = [a,b,c,d,e,f]Output:
[false,false,false,false,false,false,false,false,false,false,false,true,false]Explanation:
After streaming a,b,c,d the suffix 'cd' matches a word. After e,f the suffix 'f' matches.
Input:
words = ["abc","xyz"], queries = [x,y,z,a,b,c]Output:
[false,false,false,false,false,false,false,false,false,false,false,false,false]Explanation:
After querying 'x','y','z' the last 3 characters form 'xyz', matching a dictionary word. After 'x','y','z','a','b','c' the last 3 characters 'abc' also match.
Input:
words = ["hello","hi","world"], queries = [h,i,w,o,r,l,d,h,e,l,l,o]Output:
[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]Explanation:
After querying 'h','i' the last 2 characters form 'hi'. After 'w','o','r','l','d' the last 5 characters form 'world'. After the full sequence ending with 'h','e','l','l','o' the last 5 characters form 'hello'.
Constraints
- •
1 ≤ words.length ≤ 2000