class Solution:
def maxVowels(self, s: str, k: int) -> int:
# 边界条件
if not s or len(s)==0 or k> len(s):
return 0
# 哈希map
hashmap = { 'a', 'e', 'i', 'o', 'u'}
count, result = 0,0
# 初始滑动窗口
for i in range(k):
if s[i] in hashmap:
count += 1
result = max(result, count)
# 滑动
for i in range(k,len(s)):
if s[i-k] in hashmap:
count -= 1
if s[i] in hashmap:
count += 1
result = max(count, result)
return result