package io.anand.play;

public class ReverseVowels {

    private static boolean isVowel(char c) {

        switch (c) {
            case 'a':
            case 'e':
            case 'i':
            case 'o':
            case 'u':
            case 'A':
            case 'E':
            case 'I':
            case 'O':
            case 'U':
                return true;

            default:
                return false;
        }
    }

    private static String reverseVowels (String input) {
        // Idea would be to have a pointer from the each end of the
        // string characters. When we find a vowel, swap it with the other
        // using the index.
        // Stop when the indices cross over.
        char [] charArray = input.toCharArray();
        int left          = 0;
        int right         = charArray.length - 1;

        while ( left < right ) {
            // Go till the first vowel from left and resume the loop by continuing.
            if (!isVowel(charArray[left])) {
                left++;
                continue;
            }
            // Go till the first vowel from right
            if (!isVowel(charArray[right])) {
                right--;
                continue;
            }

            // Fact we did not continue means we have two vowels and not crossed over.
            char temp;
            temp = charArray[left];
            charArray[left] = charArray[right];
            charArray[right] = temp;

            // These are needed, else we will be in loop swapping same two vowels.
            left++;
            right--;
        }
        return new String (charArray);
    }


    public static void main (String [] args) {
        String input   = "Is this a good test for apple, say hello";
        String ooutput = reverseVowels(input);
        System.out.println("Input: " + input + ", Output: " + ooutput);
    }
}

@@ -428,24 +428,236 @@
    %7D%0A    %7D%0A%0A
+    private static void swapChars (char %5B%5D charArray, int left, int right) %7B%0A        char temp;%0A        temp = charArray%5Bleft%5D;%0A        charArray%5Bleft%5D = charArray%5Bright%5D;%0A        charArray%5Bright%5D = temp;%0A    %7D%0A%0A
     private 
@@ -697,24 +697,24 @@
 ng input) %7B%0A
-
         // I
@@ -1048,16 +1048,130 @@
 h - 1;%0A%0A
+        // Till our markers are not crossed over (means we have done swapping%0A        // all potential candidates%0A
         
@@ -1191,24 +1191,25 @@
 %3C right ) %7B%0A
+%0A
             
@@ -1381,32 +1381,33 @@
 ;%0A            %7D%0A
+%0A
             // G
@@ -1655,67 +1655,18 @@
     
-char temp;%0A            temp = charArray%5Bleft%5D;%0A            
+swapChars(
 char
@@ -1674,70 +1674,22 @@
 rray
-%5B
+, 
 left
-%5D = charArray%5Bright%5D;%0A            charArray%5Bright%5D = temp
+, right)
 ;%0A%0A 
@@ -1937,17 +1937,16 @@
  input  
- 
 = %22Is th
@@ -1998,17 +1998,16 @@
  String 
-o
 output =
@@ -2091,17 +2091,16 @@
 ut: %22 + 
-o
 output);

Add run output for reference.