Data Structures & AlgorithmsHard

What is the length of the longest contiguous substring of "aabbccabcdd" in which EVERY distinct letter appears at least twice?

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

Correct answer: C. 11

Every letter in the window must occur at least twice, which a window with a count map checks as it grows. Requiring only one copy, looking only at runs of the same letter, or adding one to the answer each give other values.

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

Exams that ask this topic