100%faster code for the problem
class Solution {\n    public int[] sortArrayByParityII(int[] nums) {\n        int result[]=new int[nums.length];\n        int j=0,k=1;\n        \n        for(in
class Solution {\n    public int[] sortArrayByParityII(int[] nums) {\n        int result[]=new int[nums.length];\n        int j=0,k=1;\n        \n        for(int i=0;i<nums.length;i++)\n        {\n            if(nums[i]%2==0)\n            {\n                result[j]=nums[i];\n                j+=2;\n            }\n            else{\n                \n            result[k]=nums[i];\n            k+=2;\n            }\n        }\n        return(result);\n        \n    }\n}
['Java']