Java 2ms (99.76% faster)
Get first even entry at the wrong index\n2. Get first odd entry at the wrong index\n3. swap\n4. repeat\n\npublic int[] sortArrayByParityII(int[] A) {\n        i
1. Get first even entry at the wrong index\n2. Get first odd entry at the wrong index\n3. swap\n4. repeat\n```\npublic int[] sortArrayByParityII(int[] A) {\n        int even = 0, odd = 1;\n        while(true){\n            while(even < A.length && A[even] % 2 == 0) /*(1)*/\n                even += 2;\n            while(odd < A.length && A[odd] % 2 != 0) /*(2)*/\n                odd += 2;\n            if(odd >= A.length || even >= A.length) return A;\n\t\t\t\n\t\t\t/*(3)*/\n            int temp = A[even];\n            A[even] = A[odd];\n            A[odd] = temp;\n        }\n    }\n```
['Java']