Notes:
1 /** 2 * Created by sheepcore on 2019-02-24 3 */ 4 class Solution { 5 public int[] sortArrayByParityII(int[] A) { 6 int k = 0, j = 1; 7 int[] res = new int[A.length]; 8 for (int i = 0; i < A.length; i++) { 9 if (A[i] % 2 == 0) { 10 res[k] = A[i]; 11 k += 2; 12 } else { 13 res[j] = A[i]; 14 j += 2; 15 } 16 } 17 return res; 18 } 19 }
LeetCode-922 Sort Array By Parity II Solution (with Java)
原文:https://www.cnblogs.com/sheepcore/p/12396178.html