力扣345. 反转字符串中的元音字母
作者:互联网
1 class Solution: 2 def reverseVowels(self, s: str) -> str: 3 left,right,word,ans = 0,len(s)-1,'aeiouAEIOU',list(s) 4 while left < right: 5 flag1,flag2 = ans[left] in word, ans[right] in word 6 if flag1 and flag2: 7 ans[left],ans[right] = ans[right],ans[left] 8 left += 1 9 right -= 1 10 left += (1 - int(flag1)) 11 right -= (1 - int(flag2)) 12 return ''.join(ans)
标签:right,word,力扣,345,flag2,flag1,ans,元音,left 来源: https://www.cnblogs.com/lj95/p/14397337.html