Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

How many binary strings of length 12 contain no three consecutive 1s and end with the digit 0?

  1. A. 927
  2. B. 1705
  3. C. 233
  4. D. 778

Correct answer: A. 927

Ending in 0 leaves any valid string of length 11 in front, so the answer is the count of valid length-11 strings. Forgetting the ending condition, or banning '11' instead of '111', each gives a different count.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic