Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

What is the length of the longest substring of "pwwkewbcab" with no repeated characters?

  1. A. 7
  2. B. 10
  3. C. 3
  4. D. 6

Correct answer: D. 6

Move the left edge past the previous occurrence only when it lies inside the window: the best is 'kewbca', length 6. Counting distinct letters gives 7, 10 is the whole string, and 3 is the classic answer for the 'pwwkew' prefix alone.

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

Exams that ask this topic