# Leetcode 324 - Wiggle sort II

Note:

• It’s not hard to come up with a way of inserting alternatively.
• Sort the whole nums first.
• Split it into half, and the first half is longer is len is odd.
• Explain: If the second one is longer, there will be a situation where the last of second has no where to go. Such as [1,4,3,4,1,2,1,3,1,3,2,3,3], it will be like [2, 4, 2, 4, 1, 3, 1, 3, 1, 3, 1, 3] without the last element. We don’t know where to put the last element 3.

Question:

Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....

You may assume the input array always has a valid answer.

Example:

Code: