【leetcode】324. 摆动排序 II
void wiggleSort(int* nums, int numsSize){ int hash[5001]={0}, i, j=0; for(i=0; i<numsSize; i++) hash[nums[i]]++; i=(numsSize%2)?numsSize-1 :numsSize-2; for(; i>=0;){ if(hash[j]){ nums[i]=j; hash[j]--; i-=2; } else j++; } i=(numsSize%2)?numsSize-2 :numsSize-1; for(; i>=0;){ if(hash[j]){ nums[i]=j; hash[j]--; i-=2; } else j++; } }