class Solution {
public:
void wiggleSort(vector<int>& nums) {
sort(nums.begin(), nums.end());
int n = nums.size(), i = (n + 1) / 2 - 1, j = n - 1;
vector<int> v = nums;
for (int k = 0; k < n; ++k) {
nums[k] = k & 1 ? v[j--] : v[i--];
}
}
};