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 cases.

&nbsp;
Example 1:
Input: s = "hello"
Output: "holle"
Example 2:
Input: s = "leetcode"
Output: "leotcede"

&nbsp;
Constraints:


	1 &lt;= s.length &lt;= 3 * 105
	s consist of printable ASCII characters.


class Solution:
    def reverseVowels(self, s: str) -> str:
        s=list(s)
        vow=[]
        for i,val in enumerate(s):
            if val in ('a','e','i','o','u','A','E','I','O','U'):
                vow.append(val)
                s[i]='_'
                
        vow=vow[::-1]
        c=0
        print(vow)
        for i,val in enumerate(s):
            if val =='_':
                s[i]=vow[c]
                c+=1
        return "".join(s)
class Solution {
    public String reverseVowels(String s) {
        Set<Character> set = new HashSet<>();
        set.add('a');
        set.add('e');
        set.add('i');
        set.add('o');
        set.add('u');
        set.add('A');
        set.add('E');
        set.add('I');
        set.add('O');
        set.add('U');
        
        StringBuilder str = new StringBuilder(s);
        int left = 0, right = str.length() - 1;
        while (left < right) {
            if (!set.contains(str.charAt(left))) {
                left++;
            }
            if (!set.contains(str.charAt(right))) {
                right--;
            }
            if (set.contains(str.charAt(left)) && set.contains(s.charAt(right))) {
                char temp = str.charAt(left);
                str.setCharAt(left++, str.charAt(right));
                str.setCharAt(right--, temp);
            }
        }
        return str.toString();
    }
}
class Solution {
public:
    
    bool isVowel(char s)
    {
        if(s == 'a' or s == 'e' or s == 'i' or s == 'o' or s == 'u'
           or s == 'A' or s == 'E' or s == 'I' or s == 'O' or s == 'U') return true;
        return false;
    }
    
    string reverseVowels(string s) {
        if(s.size() == 0) return "";
        int left = 0, right = s.size() - 1;
        
        while(left < right)
        {
            if(isVowel(s[left]) and isVowel(s[right]))
            {
                swap(s[left], s[right]);
                left++;
                right--;
            }
            else if(isVowel(s[left])) right--;
            else if(isVowel(s[right])) left++;
            else {
                left++;
                right--;
            }
        }
        
        
        return s;
    }
};
var reverseVowels = function(s) {
    const VOWELS = { 'a': 1, 'e': 1, 'i': 1, 'o': 1, 'u': 1, 'A': 1, 'E': 1, 'I': 1, 'O': 1, 'U': 1 };
    const arr = s.split('');
    let i = 0, j = arr.length - 1;
    while (i < j) {
        if (VOWELS[arr[i]] && VOWELS[arr[j]]) {
            [arr[i], arr[j]] = [arr[j], arr[i]];
            i++;
            j--;
        } else if (VOWELS[arr[i]]) {
            j--;
        } else {
            i++;
        }
    }
    return arr.join('');
};
Reverse Vowels of a String