Data Structures & AlgorithmsHard

How many binary strings of length 6 contain NO three equal bits in a row (no run of length 3 or more)?

  1. A. 26
  2. B. 62
  3. C. 20
  4. D. 60

Correct answer: A. 26

Count runs: each string is a sequence of runs of length 1 or 2 alternating in bit value, and a run-length DP gives the total. Brute force over the 64 strings confirms the value for length 6.

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

Exams that ask this topic