Python solution using stack

  • 0
    class Solution(object):
        def reverseVowels(self, s):
            :type s: str
            :rtype: str
            vowels = 'aeiouAEIOU'
            stack = []
            for char in s:
                if char in vowels:
            return ''.join(char if char not in vowels else stack.pop() for char in s)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.