Maximum Number of Vowels in a Substring

Medium

Description

Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.

Examples

Input:s = "abciiidef", k = 3
Output:3
Explanation:

"iii" has 3 vowels.

Input:s = "leetcode", k = 3
Output:2
Explanation:

The substring "eec" contains 2 vowels (e, e), which is the maximum possible for any substring of length 3.

Input:s = "programming", k = 4
Output:1
Explanation:

Multiple substrings of length 4 contain exactly 1 vowel each (like "prog", "rogr", "ogra", "gram", "ramm", "ammi", "mmin", "ming"), and this is the maximum possible.

Constraints

  • 1 ≤ s.length ≤ 10⁵

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!