Stream of Characters

Design a class StreamChecker that answers suffix questions over a growing character stream.

The constructor receives a list of dictionary words. Each call to query(letter) appends that single character to the stream and returns true when at least one dictionary word is a suffix of everything received so far, or false otherwise.

Only the newest character can complete a new match. A previous match does not force later answers: every call must test the suffixes that end at the character just appended. Dictionary words are distinct or repeated, and a single query may complete more than one word. The stream is cumulative for the lifetime of the object.

Examples
Input: []
Output: 0
Hints

Stream of Characters

Design a class `StreamChecker` that answers suffix questions over a growing character stream.