324. 摆动排序 II
作者:互联网
1 class Solution 2 { 3 public: 4 void wiggleSort(vector<int>& nums) 5 { 6 int n = nums.size(); 7 sort(nums.begin(),nums.end()); 8 vector<int> temp; 9 int mid = (n - 1) / 2; 10 int i = mid; 11 int j = n - 1; 12 while(i >= 0 && j > mid) 13 { 14 temp.push_back(nums[i --]); 15 temp.push_back(nums[j --]); 16 } 17 if(i == 0) temp.push_back(nums[0]); 18 nums = temp; 19 } 20 };
标签:temp,nums,int,back,mid,II,324,push,排序 来源: https://www.cnblogs.com/yuhong1103/p/12745704.html