Earliest Point Where a Pattern Fires on a Character Stream

Company: Jane Street_31oct

Difficulty: hard