package leetcode;

/**
 * https://leetcode.com/problems/reverse-vowels-of-a-string/
 */
public class Problem345 {
    public String reverseVowels(String s) {
        // TODO
        return "";
    }

    public static void main(String[] args) {
        Problem345 prob = new Problem345();
        System.out.println(prob.reverseVowels("hello")); // holle
        System.out.println(prob.reverseVowels("leetcode")); // leotcede
    }
}

@@ -163,268 +163,1300 @@
     
-// TODO%0A        return %22%22
+char%5B%5D chars = s.toCharArray();%0A        int leftIdx = 0
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem345 prob = new Problem345();%0A        System.out.println(prob.reverseVowels(%22hello%22)); // holle%0A        System.out.println(prob.reverseVowels(%22leetcode%22)); // leotcede
+int rightIdx = chars.length - 1;%0A        int leftVowelIdx = 0;%0A        int rightVowelIdx = rightIdx;%0A        while (leftIdx %3C= rightIdx) %7B%0A            boolean leftVowel = false;%0A            while (leftIdx %3C= rightIdx) %7B%0A                if (isVowel(chars%5BleftIdx%5D)) %7B%0A                    leftVowel = true;%0A                    leftVowelIdx = leftIdx;%0A                    break;%0A                %7D%0A                leftIdx++;%0A            %7D%0A            boolean rightVowel = false;%0A            while (rightIdx %3E= leftIdx) %7B%0A                if (isVowel(chars%5BrightIdx%5D)) %7B%0A                    rightVowel = true;%0A                    rightVowelIdx = rightIdx;%0A                    break;%0A                %7D%0A                rightIdx--;%0A            %7D%0A            if (leftVowel && rightVowel) %7B%0A                char tmp = chars%5BleftVowelIdx%5D;%0A                chars%5BleftVowelIdx%5D = chars%5BrightIdx%5D;%0A                chars%5BrightVowelIdx%5D = tmp;%0A            %7D%0A            leftIdx++;%0A            rightIdx--;%0A        %7D%0A        return new String(chars);%0A    %7D%0A%0A    private boolean isVowel(char c) %7B%0A        return (c == 'a' %7C%7C c == 'i' %7C%7C c == 'u' %7C%7C c == 'e' %7C%7C c == 'o' %7C%7C%0A                c == 'A' %7C%7C c == 'I' %7C%7C c == 'U' %7C%7C c == 'E' %7C%7C c == 'O');
 %0A   

Solve problem 345