Data Structures & AlgorithmsModerateAccenture · Infosys OA

Problem: Longest substring without repeating characters of "pwwkewabcdbbxq". What is its length?

  1. A. 8
  2. B. 5
  3. C. 10
  4. D. 7

Correct answer: D. 7

Jump the left edge to one past the previous occurrence (never backwards): the best window is 'kewabcd', length 7. Moving left only TO the previous occurrence keeps the duplicate and gives 8, restarting the window at the repeat gives 5, and counting distinct letters in the whole string gives 10.

More Coding Interview Problems questions

Exams that ask this topic