Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B

How many substrings of abcabcbb contain no repeated character?

  1. A. 18
  2. B. 20
  3. C. 16
  4. D. 23

Correct answer: A. 18

All substrings of length 1 qualify, plus the distinct-letter stretches of length 2 and 3. Counting by the sliding window's maximum length alone misses the shorter valid substrings.

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

Exams that ask this topic