按奇偶排序数组II
class Solution { public: vector<int> sortArrayByParityII(vector<int>& nums) { sort(nums.begin() , nums.end()); vector<int> result(nums.size() , 0); int left = 0 ,right = 1; for(int i=0 ; i<nums.size() ;i++) { if(nums[i]%2 == 0) { result[left] = nums[i]; left += 2; }else { result[right] = nums[i]; right += 2; } } return result; } };