Reverse Vowels of a String
Input:
"hello"
Output:
"holle"Input:
"leetcode"
Output:
"leotcede"class Solution:
def reverseVowels(self, s: str) -> str:
l = len(s)
ss,e = 0,l-1
s = list(s)
while ss < e:
while ss < e and s[ss] not in 'aeiouAEIOU':
ss += 1
while ss < e and s[e] not in 'aeiouAEIOU':
e -= 1
s[ss],s[e] = s[e],s[ss]
ss += 1
e -= 1
return ''.join(s)Last updated