https://leetcode.com/problems/reverse-vowels-of-a-string/
class Solution {
public:
string reverseVowels(string s) {
int len = s.size();
if (len <= 1){
return s;
}
int i = 0, j = len - 1;
while (i < j){
while (i < j && !isVowels(s[i]))i++;
while (i < j&&!isVowels(s[j]))j--;
if (i < j){
swap(s[i], s[j]);
i++;
j--;
}
}
return s;
}
bool isVowels(char c){
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'){
return true;
}
return false;
}
};