Data Structures & AlgorithmsHardTCS NQT · Accenture

How many substrings of the string aaabaa consist only of the letter a?

  1. A. 10
  2. B. 11
  3. C. 9
  4. D. 13

Correct answer: C. 9

The runs of a are of lengths 3 and 2, contributing 6 and 3 substrings respectively.

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

Exams that ask this topic