Data Structures & AlgorithmsHardCodeforces Div2 B · TCS NQT

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

  1. A. 9
  2. B. 15
  3. C. 3
  4. D. 8

Correct answer: D. 8

Move the left edge past the previous occurrence of the incoming character: the best window is 'kewfabcd' of length 8. Counting distinct letters overall gives 9, 15 is the whole string, and 3 is the answer to the classic 'pwwkew' prefix alone.

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

Exams that ask this topic