Longest Substring Of All Vowels in Order LeetCode solution in Python

1
class Solution:
2
def longestBeautifulSubstring(self, word: str) -> int:
3
g = ""
4
count = m = 0
5
for x in word:
6
if g and x < g[-1]:
7
count = 0
8
g = ""
9
if not g or x > g[-1]:
10
g += x
11
count += 1
12
if g == "aeiou":
13
m = max(m, count)
14
return m

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0