Fastest Solution Out There Bits on fire 💯🚀
I find this problem very similair to \n\n26. Remove Duplicates from Sorted Array\n27. Remove Element\n80. Remove Duplicates from Sorted Array II\n283. Move Zero
I find this problem very similair to \n\n[26. Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array/solutions/5505499/my-accepted-java-solution/)\n[27. Remove Element](https://leetcode.com/problems/remove-element/solutions/5505493/good-to-go/)\n[80. Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/solutions/5505483/my-accepted-java-solution-with-similar-problems/)\n[283. Move Zeroes](https://leetcode.com/problems/move-zeroes/solutions/5810033/good-to-go-okay-so-here-is-the-template/)\n[2460. Apply Operations to an Array](https://leetcode.com/problems/apply-operations-to-an-array/solutions/5810074/good-to-go-must-read-easy-template/)\n[905. Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity/solutions/5810076/fastest-solution-out-there-bits-on-fire/)\n\n\n\n# Code\n```java []\nclass Solution {\n    public int[] sortArrayByParity(int[] nums) {\n        int index =0;\n\n        for(int i=0;i<nums.length;i++){\n\n            if((nums[i]&1)==0){\n                swap(index,i,nums);\n                index++;\n            }\n        }\n        return nums;\n    }\n    \n    void swap(int i, int j, int[] nums) {\n        if (nums[i] != nums[j]) {  // Only perform swap if the indices are different to avoid zeroing out the same number\n            nums[i] = nums[i] ^ nums[j];  // Step 1: nums[i] holds the XOR of nums[i] and nums[j]\n            nums[j] = nums[i] ^ nums[j];  // Step 2: nums[j] now holds the original value of nums[i]\n            nums[i] = nums[i] ^ nums[j];  // Step 3: nums[i] now holds the original value of nums[j]\n        }\n    }\n\n}\n```
['Java']