-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1456.py
More file actions
29 lines (23 loc) · 694 Bytes
/
Copy path1456.py
File metadata and controls
29 lines (23 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Solution:
def maxVowels(self, s, k):
vowelCount = 0
maxCount = 0
vowels = {'a','e','i','o','u'}
for i in range(0,len(s)):
if i<k:
if s[i] in vowels:
vowelCount+=1
maxCount = vowelCount
continue
if s[i] in vowels:
vowelCount += 1
if s[i-k] in vowels:
vowelCount -= 1
maxCount = vowelCount if maxCount<vowelCount else maxCount
return maxCount
if __name__ == "__main__":
sol = Solution()
s = "tryhard"
k = 4
print(sol.maxVowels(s,k))
print()