Data Structures & AlgorithmsVery hardCodeforces Div 2 C · ICPC regional

How many binary strings of length 6 contain neither two consecutive 0s nor three consecutive 1s?

  1. A. 9
  2. B. 11
  3. C. 6
  4. D. 21

Correct answer: A. 9

Enumerate strings with a state DP: the state is the last one or two bits and the current run length. Dropping the '111' rule, or dropping the '00' rule, gives a different count.

More Coding Interview Problems questions

Exams that ask this topic