Stream of Characters

hard

Implement a stream checker that detects any suffix matching inserted words

Stream of Characters

Key Insight

Insert reversed dictionary words, then check stream suffixes by walking backward through the reversed trie.

Step 1Build Reversed Trie
Array
cd
0
f
1
kl
2
HashMap
dc:2
f:1
lk:2

cd, f, kl become dc, f, lk in storage.

1 / 3

Learn the Pattern

Practice the Code

Step-by-Step Walkthrough: Stream of Characters

Insert reversed dictionary words, then check stream suffixes by walking backward through the reversed trie.

  1. Build Reversed Trie

    cd, f, kl become dc, f, lk in storage.

  2. Query Stream

    Letters arrive one by one; each query tests reversed suffixes up to max word length.

  3. Match Detection

    Next character that creates suffix "cd" returns true.