625.Partition Array II
Last updated
Last updated
public void partition2(int[] nums, int low, int high) {
if(nums==null || nums.length==0){
return;
}
int left=0;
int right=nums.length-1;
int i=0;
while(i<=right){
if(nums[i]<low){
swap(nums,i,left);
i++;
left++;
}
else if(nums[i]>high){
swap(nums,i,right);
right--;
}else{
i++;
}
}
}
public void swap(int[] colors,int i,int j){
int temp=colors[i];
colors[i]=colors[j];
colors[j]=temp;
}