Data Structures & AlgorithmsVery hardTCS NQT · Accenture

How many contiguous non-empty substrings of aaabbbaa consist of a single repeated letter?

  1. A. 15
  2. B. 16
  3. C. 17
  4. D. 19

Correct answer: A. 15

Runs of length 3, 3 and 2 contribute 6, 6 and 3 substrings, so the total is 15.

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

Exams that ask this topic