c++  two pointer methode
Intuition\nall even will be stays left and odds right. if even presents right side and odd presents left side swap them to keep it as condition.\n Describe your
# Intuition\nall even will be stays left and odds right. if even presents right side and odd presents left side swap them to keep it as condition.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\na iterator travarse from left side if hit a odd stop there.\nas well as an another iterator travarse from right side and stop when hit a even . then swap themselves.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1);\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> sortArrayByParity(vector<int>& nums) {\n        int n = nums.size();\n        int i = 0, j = n - 1;\n        while(i < j)\n        {\n            for(i; i < j && nums[i] % 2 == 0; i++);\n            for(j; j > i && nums[j] % 2 != 0; j--);\n            if(i >= j) break;\n            swap(nums[i], nums[j]); \n        }\n        return nums;\n    }\n};\n```
['C++']