345. Reverse Vowels of a String (转置字符串中的元音字母)

Write a function that takes a string as input and reverse only the vowels of a string.

Example 1:
Given s = "hello", return "holle".

Example 2:
Given s = "leetcode", return "leotcede".

Note:

The vowels does not include the letter "y".

public class Solution {
    public String reverseVowels(String s) {
        if(s==null||s.length()<=1)
        return s;
        StringBuffer sb = new StringBuffer(s);
        char temp;
        int left = 0,right = sb.length()-1;
        while(true){
        	while(left-1&&!isVowel(sb.charAt(right)))
        		right--;
        	if(right==-1)
        		return sb.toString();
        	if(left


你可能感兴趣的:(leetcode,LeetCode,Solutions,In,Java)