Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: How many runs (maximal blocks of equal consecutive characters) does "aabbbaaaacc" contain?

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

Correct answer: C. 4

Runs are counted by the number of positions where the character changes, plus one. Counting distinct letters instead merges the separated runs of 'a'.

More Coding Interview Problems questions

Exams that ask this topic