#include <bits/stdc++.h> using namespace std; class Solution { public: void wiggleSort(vector<int> &nums) { int n = nums.size(); vector<int> tmp(nums); sort(tmp.begin(), tmp.end()); int mid = n / 2, end = n - 1; if (n % 2 == 0) mid--; for (int i = 0; i < n; i++) { nums[i] = i % 2 == 0 ? tmp[mid--] : tmp[end--]; } } };