Data Structures & AlgorithmsHardGATE CS · ICPC regional

What is the length of the longest substring of aabbcaabcc in which every character occurs at least twice?

  1. A. 11
  2. B. 12
  3. C. 10
  4. D. 14

Correct answer: C. 10

Check candidate substrings by counting letters: a window with a letter occurring once is invalid even if its other letters repeat. Only maximal valid windows matter.

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

Exams that ask this topic