Given an array A of n elements, rearrange the array according to the following relations :
, if i is even.
, if i is odd.[Considering 1-indexed array]
Print the resultant array.
The first line of the input contains an integer T, denoting number of test cases. The first line of each test case contains an integer N denoting the size of the array. The second line of each test cases N space separated integers.
For each test case, print rearranged array.
1 2 2 1
1 3 2
1 2 1 2
1 3 2
Both 2 are at even positions and 1 at odd satisfying given condition
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.