✅95.92%🔥Easy Solution🔥2 linear code🔥
Python3 []\nclass Solution:\n    def sortArrayByParity(self, nums: List[int]) -> List[int]:\n        nums[:] = [i for i in nums if i%2==0] + [j for j in nums if
```Python3 []\nclass Solution:\n    def sortArrayByParity(self, nums: List[int]) -> List[int]:\n        nums[:] = [i for i in nums if i%2==0] + [j for j in nums if j%2!=0]\n        return nums\n```\n```python []\nclass Solution:\n    def sortArrayByParity(self, nums: List[int]) -> List[int]:\n        nums[:] = [i for i in nums if i%2==0] + [j for j in nums if j%2!=0]\n        return nums\n```\n```C# []\npublic class Solution\n{\n    public int[] SortArrayByParity(int[] nums)\n    {\n        List<int> evenNumbers = nums.Where(i => i % 2 == 0).ToList();\n        List<int> oddNumbers = nums.Where(j => j % 2 != 0).ToList();\n        \n        evenNumbers.AddRange(oddNumbers);\n        \n        return evenNumbers.ToArray();\n    }\n}\n\n```\n```C++ []\nclass Solution {\npublic:\n    std::vector<int> sortArrayByParity(std::vector<int>& nums) {\n        std::vector<int> result;\n        for (int i : nums) {\n            if (i % 2 == 0) {\n                result.push_back(i);\n            }\n        }\n        for (int j : nums) {\n            if (j % 2 != 0) {\n                result.push_back(j);\n            }\n        }\n        return result;\n    }\n};\n\n```\n```C []\nint* sortArrayByParity(int* nums, int numsSize, int* returnSize) {\n    int* result = (int*)malloc(numsSize * sizeof(int));\n    int evenIndex = 0;\n    int oddIndex = numsSize - 1;\n\n    for (int i = 0; i < numsSize; i++) {\n        if (nums[i] % 2 == 0) {\n            result[evenIndex] = nums[i];\n            evenIndex++;\n        } else {\n            result[oddIndex] = nums[i];\n            oddIndex--;\n        }\n    }\n\n    *returnSize = numsSize;\n    return result;\n}\n\n```\n```Java []\npublic class Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        int[] result = new int[nums.length];\n        int evenIndex = 0;\n        int oddIndex = nums.length - 1;\n        \n        for (int num : nums) {\n            if (num % 2 == 0) {\n                result[evenIndex] = num;\n                evenIndex++;\n            } else {\n                result[oddIndex] = num;\n                oddIndex--;\n            }\n        }\n        \n        return result;\n    }\n}\n\n```\n```javascript []\nvar sortArrayByParity = function(nums) {\n    const result = [];\n    \n    for (const num of nums) {\n        if (num % 2 === 0) {\n            result.unshift(num);\n        } else {\n            result.push(num);\n        }\n    }\n    \n    return result;\n};\n\n```\n```Go []\nfunc sortArrayByParity(nums []int) []int {\n    even := []int{}\n    odd := []int{}\n\n    for _, num := range nums {\n        if num%2 == 0 {\n            even = append(even, num)\n        } else {\n            odd = append(odd, num)\n        }\n    }\n\n    even = append(even, odd...)\n    return even\n}\n\n```\n```Rust []\nimpl Solution {\n    pub fn sort_array_by_parity(nums: Vec<i32>) -> Vec<i32> {\n        let mut even = Vec::new();\n        let mut odd = Vec::new();\n\n        for num in nums {\n            if num % 2 == 0 {\n                even.push(num);\n            } else {\n                odd.push(num);\n            }\n        }\n\n        even.extend(odd);\n        even\n    }\n}\n\n```\n
['Array', 'C', 'Python', 'C++', 'Java', 'Go', 'Python3', 'Rust', 'JavaScript', 'C#']