Skip to content

Commit d18a016

Browse files
add 1456-maximum-number-of-vowels-in-a-substring-of-given-length.py
1 parent 4bb2c73 commit d18a016

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def maxVowels(self, s: str, k: int) -> int:
3+
l, res, total = 0, 0, 0
4+
vowels = "aeiou"
5+
6+
for r in range(len(s)):
7+
if s[r] in vowels:
8+
total += 1
9+
if (r - l + 1) > k:
10+
if s[l] in vowels:
11+
total -= 1
12+
l += 1
13+
res = max(res, total)
14+
return res
15+
16+
17+

0 commit comments

Comments
 (0)