Wiggle Sort

Medium

📝 Description

Reorder array so nums[0] ≤ nums[1] ≥ nums[2] ≤ nums[3]... (in-place)

Input Format

Space-separated array elements

Output Format

Wiggle-sorted array

Constraints

1 ≤ nums.length ≤ 5 * 10^4

🔍 Sample Input

3 5 2 1 6 4
            

✅ Sample Output

3 5 1 6 2 4
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run