Given an array A (distinct elements) of size N. Rearrange the elements of array in zig-zag fashion. The converted array should be in form a < b > c < d > e < f. The relative order of elements is same in the output i.e you have to iterate on the original array only.
The first line of input contains an integer T denoting the number of test cases. T testcases follow. Each testcase contains two lines of input. The first line contains a single integer N denoting the size of array.
The second line contains N space-separated integers denoting the elements of the array.
For each testcase, print the array in Zig-Zag fashion.
1 <= T <= 100
1 <= N <= 100
0 <= Ai <= 10000
4 3 7 8 6 2 1
1 4 3 2
3 7 4 8 2 6 1
1 4 2 3
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.