classSolution:defreverseVowels(self, s:str)->str:"""
双指针法
"""
Vowels =['a','e','i','o','u','A','E','I','O','U']
s =list(s)
l, r =0,len(s)-1while l < r:if s[l]in Vowels and s[r]in Vowels:
s[l],s[r]= s[r],s[l]
l +=1
r -=1elif s[l]in Vowels:
r -=1elif s[r]in Vowels:
l +=1else:
l +=1
r -=1return''.join(s)