#include using namespace std; class Solution { public: void wiggleSort(vector &nums) { int n = nums.size(); vector 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--]; } } };