Given a sorted array arr of non-repeating integers without duplicates. 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..... (considering the increasing lexicographical order).
The first line contains an integer T, depicting total number of test cases. T testcases follow. The first line of each testcase contains an integer N depicting the size of the array. The second line contains N space separated elements of the array.
For each testcase, in a new line, print the array into wave-like array.
1 ≤ T ≤ 100
1 ≤ N ≤ 106
0 ≤ A[i] ≤107
1 2 3 4 5
2 1 4 3 5
Testcase 1: Array elements after sorting it in wave form are 2 1 4 3 5 .
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.