254. Maximum Number of Vowels in a Substring of Given Length

MediumStringString

Given a string s and integer k, return the maximum number of vowel letters (a, e, i, o, u) in any contiguous substring of length k. Input: '"s", k'.

Input: '"s", k'.

Output: Integer — maximum vowel count.

Examples

Example 1
Input: "abciiidef", 3
Output: 3
Explanation: 'iii' has 3 vowels.
Example 2
Input: "aeiou", 2
Output: 2
Explanation: Any window of 2 vowels.
Example 3
Input: "leetcode", 3
Output: 2
Explanation: 'eet' or 'ode' has 2 vowels.

Constraints

Asked by

AmazonMicrosoftBloombergGoogleMeta
Solve this problem in the editor →