Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: How many binary strings of length 6 contain neither the substring "00" nor "11"?

  1. A. 3
  2. B. 1
  3. C. 2
  4. D. 4

Correct answer: C. 2

Only alternating strings qualify, so each of the two starting digits forces the whole string. Counting strings with no run of length three treats a different constraint.

More Coding Interview Problems questions

Exams that ask this topic