题目
代码
class Solution {
private final static HashSet<Character> yy = new HashSet<>(Arrays.asList('a','e','i','o','u','A','E','I','O','U'));
public String reverseVowels(String s) {
int i = 0;
int j = s.length() - 1;
char[] c = new char[s.length()];
while (i <= j) {
char ci = s.charAt(i);
char cj = s.charAt(j);
if (!yy.contains(ci)) {
c[i++] = ci;
} else if (!yy.contains(cj)) {
c[j--] = cj;
} else {
c[j--] = ci;
c[i++] = cj;
}
}
return new String(c);
}
}