Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

Greedy removal: scanning "aabaacaab" left to right, you delete any 'a' that immediately follows another 'a' in the current output. How many characters are deleted?

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

Correct answer: A. 3

A single pass keeping an output stack and dropping repeats gives the number of deletions. Deleting every second 'a' globally gives the same count only by coincidence here.

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

Exams that ask this topic