Find the maximum number of vowels in any substring of length .
Given a string and a fixed window length , examine every contiguous substring of length and determine the largest number of vowels contained in any one of them. Vowels are typically considered to be a, e, i, o, and u.
The goal is to efficiently track the vowel count as the window moves across the string instead of recomputing the count from scratch for each substring.
sk representing the substring lengthAssume the substring length is valid for the given string.
k.Example 1
Input
s = "abciiidef", k = 3
Output
3
Explanation
The substring "iii" contains 3 vowels, which is the maximum possible.
Example 2
Input
s = "aeiou", k = 2
Output
2
Explanation
Any length-2 substring contains exactly 2 vowels, so the answer is 2.
Example 3
Input
s = "leetcode", k = 3
Output
2
Explanation
The best length-3 substrings such as "lee" and "eet" contain 2 vowels.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.