class Solution {
public int maxVowels(String s, int k) {
int n = s.length();//字符串的长度
int left = 0;
int right = 0;
int total = 0;
int ans = 0;
for(right = 0 ;right < k;right++){
if(isvowel(s.charAt(right)) == true)
total += 1;
}
ans = Math.max(ans,total);
for(right = k ;right < n;right++){
if(isvowel(s.charAt(left)) == true)
total -= 1;
left += 1;
if(isvowel(s.charAt(right)) == true)
total += 1;
ans = Math.max(ans,total);
}
return ans;
}
public boolean isvowel(char ch){//判断一个字母是否是元音字母
return ch == 'a' || ch =='e' || ch =='i' || ch =='o' || ch =='u';
}
}