Good to go 💯🚀
26. Remove Duplicates from Sorted Array\n27. Remove Element\n80. Remove Duplicates from Sorted Array II\n283. Move Zeroes\n2460. Apply Operations to an Array\n9
[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[2418. Sort the People](https://leetcode.com/problems/sort-the-people/solutions/5810092/goo-to-go-all-possible-solution/)\n\n# Code\n```java []\nclass Solution {\n    public int[] sortArrayByParityII(int[] nums) {\n        int i = 0, j = 1, n = nums.length;\n\n        while (i < n && j < n) {\n            // Find the next even index with an odd number\n            while (i < n && (nums[i] & 1) == 0) {\n                i += 2;\n            }\n            // Find the next odd index with an even number\n            while (j < n && (nums[j] & 1) == 1) {\n                j += 2;\n            }\n            // If both indices are valid, swap the elements\n            if (i < n && j < n) {\n                swap(i, j,nums);\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']