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

Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

&nbsp;
Example 1:

Input: s = "abciiidef", k = 3
Output: 3
Explanation: The substring "iii" contains 3 vowel letters.


Example 2:

Input: s = "aeiou", k = 2
Output: 2
Explanation: Any substring of length 2 contains 2 vowels.


Example 3:

Input: s = "leetcode", k = 3
Output: 2
Explanation: "lee", "eet" and "ode" contain 2 vowels.


&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 105
	s consists of lowercase English letters.
	1 &lt;= k &lt;= s.length


class Solution:
    def maxVowels(self, s: str, k: int) -> int:
        
        def find_count_vowels(string):
            lst_vowels= ['a', 'e', 'i', 'o', 'u']
            c=0
            for i in string:
                if i in lst_vowels:
                    c+=1
            return c
            
        
        lst_vowels= ['a', 'e', 'i', 'o', 'u']
        if k>len(s):
            return find_count_vowels(s)
        dp = [0]*(len(s)-k+1)
        dp[0] = find_count_vowels(s[:k])
        for i in range(1,len(s)-k+1):
            
           
            if s[i-1] in lst_vowels and s[i+k-1] in lst_vowels:
                dp[i] = dp[i-1]
            elif s[i-1] in lst_vowels and s[i+k-1] not in lst_vowels:
                dp[i] = dp[i-1] - 1

            elif s[i-1] not in lst_vowels and s[i+k-1] in lst_vowels:
                dp[i] = dp[i-1] + 1
            else:
                dp[i] = dp[i-1]
        return max(dp)
                
class Solution {
    public int maxVowels(String s, int k) {
        int max=0,cnt=0;
        for(int i=0,j=0;j<s.length();j++){
            if(j-i+1<k){
                if(s.charAt(j)=='a' ||s.charAt(j)=='e' || s.charAt(j)=='i' || s.charAt(j)=='o' || s.charAt(j)=='u' ){
                    cnt++;
                }
            }
            else{
                if(s.charAt(j)=='a' ||s.charAt(j)=='e' || s.charAt(j)=='i' || s.charAt(j)=='o' || s.charAt(j)=='u'){
                    cnt++;
                }
                max=Math.max(max,cnt);
                if(s.charAt(i)=='a' ||s.charAt(i)=='e' || s.charAt(i)=='i' || s.charAt(i)=='o' || s.charAt(i)=='u'){
                    cnt--;
                }
                i++;
            }
            
        }
        return max;
    }
}
class Solution {
public:
    bool checkVowel(char c){
        if(c == 'a' || c == 'e' || c =='i' || c == 'o' || c == 'u') return true;
        return false;
    }
    int maxVowels(string s, int k) {
        int count = 0;
        int ans = 0;
        for(int i = 0; i < k; i++){
            if(checkVowel(s[i])) count++;
        }
        ans = count;
        int j = 0;
        for(int i = k; i<s.size(); i++){
            if(checkVowel(s[i])) count++;
            if(checkVowel(s[j])) count--;
            j++;
            ans = max(ans, count);
        }
        return ans;
    }
};
var maxVowels = function(s, k) {
    let vowels = ['a', 'e', 'i', 'o', 'u'];
    let maxCount = 0;
    let start = 0; // the left edge of the window
    let count = 0; // count of vowels for current substring
	// expanding the right edge of the window one character at a time
    for (let end = 0; end < s.length; end++) {
	    // increment count of vowels for current substring if the current character is present in vowels array
        if (vowels.includes(s[end])) {
            count +=1;
        }
        // if substring is longer than K, let's shrink the window by moving left edge
        if (end - start + 1 > k) {
			// reduce the current count by one if the character on the left edge is vowel
            if(vowels.includes(s[start])) {
                count -=1;
            }
			//shrinking the left edge of the window
            start +=1;
        }
		// checking if current count is larger than current maximum count
        maxCount = Math.max(maxCount, count)
		// if maxCount is equal to K, no need to check further, it is the max possible count
        if (maxCount == k) return maxCount;
    }
    return maxCount;
};
Maximum Number of Vowels in a Substring of Given Length