力扣第905题 按奇偶排序数组
class Solution {
public:
vector<int> sortArrayByParity(vector<int>& A) {
int len = A.size();
int left = 0, right = len - 1;
while (true)
{
while (len > left && !(A[left] & 1)) left++;
while (right >=0 && A[right] & 1) right--;
if (left >= right)
{
break;
}
A[left] = A[left] + A[right];
A[right] = A[left] - A[right];
A[left] = A[left] - A[right];
}
return A;
}
};