Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B

How many substrings of aabacbebebe contain exactly two distinct characters?

  1. A. 24
  2. B. 21
  3. C. 26
  4. D. 22

Correct answer: D. 22

Count substrings with at most two distinct characters and subtract those with at most one; the difference is the exactly-two count.

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

Exams that ask this topic