Data Structures & AlgorithmsModerateProduct placement · Amazon/Microsoft

A fixed sliding window of length 5 moves over "programmingisfun". What is the maximum number of vowels (a, e, i, o, u) inside any window?

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

Correct answer: A. 2

Count vowels in the first window, then add the entering character and subtract the leaving one at each step. The best window holds 2 vowels; 5 is the vowel count of the whole string.

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

Exams that ask this topic