Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

What is the minimum number of characters that must be deleted from the binary string "1101001110" so that no two adjacent characters are equal?

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

Correct answer: D. 4

Deleting one character from each run of equal adjacent characters makes the string alternate, so the cost is the number of adjacent equal pairs. Counting positions of 1 (last option) is unrelated.

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

Exams that ask this topic