Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

Replacing at most one character, what is the length of the longest substring of "abcbbbcaa" that can be made into a single repeated letter?

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

Correct answer: C. 5

For each target letter, slide a window that allows at most one mismatched character and take the best. The window "bcbbb" uses the single replacement of c.

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

Exams that ask this topic