✅C++ solution using Two Pointer approach with time complexity
If you\u2019re interested in coding you can join my Discord Server, link in the comment section. Also if you find any mistakes please let me know. Thank you!\u2
> **If you\u2019re interested in coding you can join my Discord Server, link in the comment section. Also if you find any mistakes please let me know. Thank you!\u2764\uFE0F**\n> \n---\n\n## Explanation:\n\n### Solution 01\n\n- Using ***Two Pointers.***\n- We\u2019ll start both pointers from the 0th index. ***i*** will iterate the whole array & ***x*** will keep track from which index odd numbers will start.\n- If the number at ***ith*** index is even then swap it with ***xth*** index & increase x.\n- **Time complexity:** O(n).\n\n---\n\n## Code:\n\n```cpp\n//Solution 01:\nclass Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& nums) {\n        int x=0;\n        for(int i=0; i<nums.size(); i++){\n            if(nums[i] % 2 == 0){\n                swap(nums[i], nums[x]);\n                x++;\n            }\n        }\n        return nums;\n    }\n};\n```\n\n---\n\n> **Please upvote this solution**\n>
['Two Pointers', 'C', 'C++']