思路:
// @Title: 训练计划 I (训练计划 I)
// @Author: qisiii
// @Date: 2022-02-20 17:52:00
// @Runtime: 2 ms
// @Memory: 49.2 MB
// @comment:
// @flag:
class Solution {
public int[] exchange(int[] nums) {
int left=0;
int right=nums.length-1;
while(left<right){
while(left<right&&nums[right]%2==0){
right--;
}
while(left<right&&nums[left]%2==1){
left++;
}
if(left<right){
int temp=nums[left];
nums[left]=nums[right];
nums[right]=temp;
}
}
return nums;
}
}