Video Editorial | Optimal C++ solution
https://www.youtube.com/watch?v=Nn4qlbHcIoY&feature=youtu.be\n\n```\nvector sortArrayByParity(vector& nums) {\n        int i=0,j=nums.size()-1;\n        while(i
https://www.youtube.com/watch?v=Nn4qlbHcIoY&feature=youtu.be\n\n```\nvector<int> sortArrayByParity(vector<int>& nums) {\n        int i=0,j=nums.size()-1;\n        while(i<j)\n        {\n            if(nums[i]%2==0)\n                i++;\n            else\n                if(nums[j]%2==1)\n                    j--;\n            else\n                swap(nums[i],nums[j]),i++,j--;\n        }\n        return nums;\n        \n        //O(n) in time\n        //O(1) in space\n    }\n\t\'\'\'\n\t\n\tPlease upvote if you found this helpful :)\n
['Two Pointers', 'C']