# https://[Log in to view URL]
# Given a string s, reverse only all the vowels in the string and return it.

# The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once.

# Example 1:

# Input: s = "hello"
# Output: "holle"

# Example 2:

# Input: s = "leetcode"
# Output: "leotcede"

class Solution:
    def reverseVowels(self, s: str) -> str:
        result = list(s)
        start, end = 0, len(s) - 1
        vowels = 'aeiouAEIOU'
        while start < end:
            while start < end and result[start] not in vowels:
                start += 1
            while start < end and result[end] not in vowels:
                end -= 1
            result[start], result[end] = result[end], result[start]
            start += 1
            end -= 1

        return "".join(result)

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: