Package g0301_0400.s0324_wiggle_sort_ii
Class Solution
java.lang.Object
g0301_0400.s0324_wiggle_sort_ii.Solution
324 - Wiggle Sort II.<p>Medium</p>
<p>Given an integer array <code>nums</code>, reorder it such that <code>nums[0] < nums[1] > nums[2] < nums[3]...</code>.</p>
<p>You may assume the input array always has a valid answer.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,5,1,1,6,4]</p>
<p><strong>Output:</strong> [1,6,1,5,1,4]</p>
<p><strong>Explanation:</strong> [1,4,1,5,1,6] is also accepted.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,3,2,2,3,1]</p>
<p><strong>Output:</strong> [2,3,1,3,1,2]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums.length <= 5 * 10<sup>4</sup></code></li>
<li><code>0 <= nums[i] <= 5000</code></li>
<li>It is guaranteed that there will be an answer for the given input <code>nums</code>.</li>
</ul>
<p><strong>Follow Up:</strong> Can you do it in <code>O(n)</code> time and/or <strong>in-place</strong> with <code>O(1)</code> extra space?</p>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
wiggleSort
public void wiggleSort(int[] nums)
-