Data Structures & AlgorithmsHardInfosys · Strings

What is the length of the longest substring of "abcabcbbxyzab" with no repeated character?

  1. A. 3
  2. B. 4
  3. C. 5
  4. D. 6

Correct answer: C. 5

A repeat-free window slides over the string; the longest is "bxyza" (length 5) - not the early "abc" (3), and extending to "bxyzab" repeats b.

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

Exams that ask this topic