public class Solution {
/**
* @param nums a list of integer
* @return void
*/
public void wiggleSort(int[] nums) {
// Write your code here
if(nums.length==0){
return;
}
Arrays.sort(nums);
int mid=0;
if(nums.length%2==0){
mid=nums.length/2-1;
}else{
mid=nums.length/2;
}
for(int i=mid+1;i<(nums.length+mid+1)/2;i++){
int temp=nums[i];
nums[i]=nums[nums.length-i+mid];
nums[nums.length-i+mid]=temp;
}
for(int i=mid+1;i<nums.length;i++){
int temp=nums[i];
System.arraycopy(nums, (i-mid-1)*2+1, nums, (i-mid-1)*2+1+1, i-(i-mid-1)*2-1);
nums[(i-mid-1)*2+1]=temp;
}
}
}