public void wiggleSort(int[] nums) {
        if (nums == null) return;

        for (int i = 1; i < nums.length; ++i) {
            if ((i & 1) == 1) {
                if (nums[i] < nums[i - 1]) swap(nums, i, i - 1);
            } else {
                if (nums[i] > nums[i - 1]) swap(nums, i, i - 1);
            }
        }
    }