Problem 1955 · Hard

Count Number of Special Subsequences

Count subsequences made of nonempty blocks of zeros, then ones, then twos. The visual scans the string with three running counters, one for each phase, updated as each character is read.

Open the interactive visualisation