

Given ‘N’ = 4,
'ARR' = { 4, 3, 2, 1}
Then a possible array is 3, 4, 1, 2.
You are supposed to return the array, which is in a zig-zag fashion.
Since there can be multiple answers for a particular array, any of the possible solutions are accepted.
It can be proved. A zig-zag array is always possible for a given array.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of each test case contains a single integer, ‘N,’ where ‘N’ is the number of elements of the array.
The second line of each test case contains ‘N’ space-separated integers, denoting the array elements.
For each test case, You are supposed to return a zig-zag array for the given array. The runner function will print a single line containing a single integer which denotes whether the returned array is in zig-zag fashion or not.
You are not required to print the expected output; it has already been taken care of. Just implement the function.
1 <= ‘T’ <= 10
1 <= ‘N’ <= 5*10^3
0 <= 'ARR'[i] <= 10 ^ 6
Time Limit: 1sec.
The idea is to sort the array and swap the pair of elements starting from index 1 (0-based Indexing).
The steps are as follows:
The idea is to use a modified one pass of bubble sort. This means swapping elements if they are not in position.
The steps are as follows: