🔢 5. 2 Easy Solutions !! || Concise & Clean Codes ! || C++ Code Reference !
2 Approaches !! \ncpp [Approach 1]\n\n    vector<int> sortArrayByParityII(vector<int>& A) {\n        \n        int i=0, j=1, n=A.size();\n\n        while(i<n &&
## 2 Approaches !! \n```cpp [Approach 1]\n\n    vector<int> sortArrayByParityII(vector<int>& A) {\n        \n        int i=0, j=1, n=A.size();\n\n        while(i<n && j<n)\n        {\n            if(A[i]%2==0) i+=2;\n            else if (A[j]&1) j+=2;\n            else swap(A[i],A[j]);\n        }\n\n        return A;\n    }\n\n\n```\n```cpp [Approach 2]\n\n    vector<int> sortArrayByParityII(vector<int>& A) {\n\n        int i=0, j=1, n=A.size();\n\n        while(1)\n        {\n            while(i<n && A[i]%2==0) i+=2;\n            while (j<n && A[j]&1) j+=2;\n\n            if(i>n || j>n) return A;\n             swap(A[i],A[j]);\n        }\n    }\n\n\n```\n\n\n---\n# *Guy\'s Upvote Pleasee !!* \n![up-arrow_68804.png](https://assets.leetcode.com/users/images/05f74320-5e1a-43a6-b5cd-6395092d56c8_1719302919.2666397.png)\n\n# ***(\u02E3\u203F\u02E3 \u035C)***\n\n\n
['Array', 'Two Pointers', 'Sorting', 'C++']