Data Structures & AlgorithmsHard

In the string "abciiidefoeuxyz", what is the largest number of vowels (a, e, i, o, u) that appear in any contiguous window of length 3?

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

Correct answer: B. 3

A fixed-length window's vowel count changes by at most one per slide, so update it in O(1) and track the maximum. Using a different window length, or counting vowels in the whole string, measures other things.

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

Exams that ask this topic