905. 按奇偶排序数组
class Solution {
public:
vector<int> sortArrayByParity(vector<int>& nums) {
int i=0,j=nums.size()-1;
while(i<nums.size()-1 && i<j){
while(i<j && (nums[i]%2==0))i++;
while(i<j && nums[j]%2==1)j--;
int t=nums[i];
nums[i]=nums[j];
nums[j]=t;
i++;j--;
}
return nums;
}
};