Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

How many binary strings of length 9 contain NO occurrence of the substring 010?

  1. A. 202
  2. B. 114
  3. C. 503
  4. D. 200

Correct answer: D. 200

Build the count with an automaton of states that remember how much of '010' is currently matched. Subtracting the strings that have one occurrence gives a wrong count, because an occurrence can be counted more than once.

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

Exams that ask this topic