Skip to content

Latest commit

 

History

History
22 lines (13 loc) · 534 Bytes

wave.md

File metadata and controls

22 lines (13 loc) · 534 Bytes

Wave

Given and array of integers sort the array into a wave-like array.

In other words, rearrange the elements into a sequence such that $$a_1 \ge a_2 \le a_3 \ge a_4 \le a_5 \ldots$$

If multiple solutions are available, return lexicographically smaller.

Example

Input: [1, 2, 3, 4]
Output: [2, 1, 4, 3]

Solution coming up... :)