package leetcode;

/**
 * https://leetcode.com/problems/sort-array-by-parity-ii/
 */
public class Problem922 {
    public int[] sortArrayByParityII(int[] A) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem922 prob = new Problem922();
        System.out.println(prob.sortArrayByParityII(new int[]{4, 2, 5, 7})); // [4,5,2,7]
    }
}

@@ -164,222 +164,605 @@
     
-// TODO%0A        return null;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem922 prob = new Problem922();%0A        System.out.println(prob.sortArrayByParityII(new int%5B%5D%7B4, 2, 5, 7%7D)); // %5B4,5,2,7%5D
+int%5B%5D odd = new int%5B(A.length / 2) + 1%5D;%0A        int%5B%5D even = new int%5B(A.length / 2) + 1%5D;%0A        int oddIdx = 0;%0A        int evenIdx = 0;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            if (A%5Bi%5D %25 2 == 0) %7B%0A                even%5BevenIdx++%5D = A%5Bi%5D;%0A            %7D else %7B%0A                odd%5BoddIdx++%5D = A%5Bi%5D;%0A            %7D%0A        %7D%0A        oddIdx = 0;%0A        evenIdx = 0;%0A        for (int i = 0; i %3C A.length; i++) %7B%0A            if (i %25 2 == 0) %7B%0A                A%5Bi%5D = even%5BevenIdx++%5D;%0A            %7D else %7B%0A                A%5Bi%5D = odd%5BoddIdx++%5D;%0A            %7D%0A        %7D%0A        return A;
 %0A   

Solve problem 922