/**
* Note: The returned array must be malloced, assume caller calls free().
*/
int* exchange(int* nums, int numsSize, int* returnSize){
int i = 0, j = numsSize-1;
while(i<j){
while((i<numsSize)&&(nums[i]%2==1)){
i++;
}
while((j>=0)&&(nums[j]%2==0)){
j--;
}
if(i<j){
returnSize[0] = nums[i];
nums[i] = nums[j];
nums[j] = returnSize[0];
}
}
returnSize[0] = numsSize;
return nums;
}