Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: In the string "abciiidef", what is the maximum number of vowels (a, e, i, o, u) in any contiguous substring of length 4?

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

Correct answer: B. 3

A fixed-size sliding window tracks the vowel count as it moves; the maximum over windows is the answer. Counting vowels across the whole string gives a much larger number.

More Coding Interview Problems questions

Exams that ask this topic