LeetCode Solutions/May 2022 LeetCoding Challenge/Sort Array By Parity.java
<gh_stars>0class Solution {
    public int[] sortArrayByParity(int[] nums) {
        int left = 0;
        int right = nums.length - 1;
        while(left < right){
            if(nums[left] % 2 == 1){
                int temp = nums[left];
                nums[left] = nums[right];
                nums[right] = temp;
                right -= 1;
            } else{
                left += 1;
            }
        }
        return nums;
    }
}