https://leetcode-cn.com/problems/reverse-vowels-of-a-string/
编写一个函数,以字符串作为输入,反转该字符串中的元音字母。
class Solution {
public static String reverseVowels(String s) {
char[] c = s.toCharArray();
int max = c.length;
for (int i = 0; i < max; i++) {
if (ifyy(c[i])) {
while (!ifyy(c[max-1])) {
max--;
}
char swap = c[max-1];
c[max-1] = c[i];
c[i] = swap;
max--;
}
}
return String.valueOf(c);
}
static boolean ifyy(char c) {
switch (c) {
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
return true;
}
return false;
}
}