Data Structures & AlgorithmsModerateTCS NQT · Codeforces Div2 B

What is the minimum number of single-character flips needed to make "1101001011" alternate (no two adjacent characters equal)?

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

Correct answer: B. 5

Compare the string with the two alternating patterns 0101... and 1010... position by position and take the cheaper count. Counting equal adjacent pairs does not account for flipping one character to fix two pairs at once.

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

Exams that ask this topic