Problem Description
Given an array of integers A, sort the array into a wave-like array and return it.
In other words, arrange the elements into a sequence such that
a1 >= a2 <= a3 >= a4 <= a5.....
NOTE: If multiple answers are possible, return the lexicographically smallest one.
1 <= len(A) <= 106
1 <= A[i] <= 106
The first argument is an integer array A.
Return an array arranged in the sequence as described.
Input 1:
A = [1, 2, 3, 4]
Input 2:
A = [1, 2]
Output 1:
[2, 1, 4, 3]
Output 2:
[2, 1]
Explanation 1:
One possible answer : [2, 1, 4, 3] Another possible answer : [4, 1, 3, 2] First answer is lexicographically smallest. So, return [2, 1, 4, 3].
Explanation 1:
Only possible answer is [2, 1].
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.