Python
class Solution: def reverseVowels(self, s): """ :type s: str :rtype: str """ s = list(s) left = 0 right = len(s) - 1 while right > left: if not self.is_vowels(s[left]): left += 1 if not self.is_vowels(s[right]): right -= 1 if self.is_vowels(s[left]) and self.is_vowels(s[right]): tmp = s[left] s[left] = s[right] s[right] = tmp left += 1 right -= 1 return ''.join(s) def is_vowels(self, s): if s.lower() in ['a', 'e', 'i', 'o', 'u']: return True else: return False