Rearrange the array
Basic Accuracy: 41.06% Submissions: 4605 Points: 1

Given an array of integers, task is to print the array in the order – smallest number, Largest number, 2nd smallest number, 2nd largest number, 3rd smallest number, 3rd largest number and so on..

Input:
The first line consists of an integer T i.e number of test cases. The first line of each test case consists of an integer N.The next line consists of N spaced integers. 

Output:
Print the required answer.

Constraints: 
1<=T<=100
1<=N,a[i]<=1000

Example:
Input:

2
9
1 9 2 8 3 7 4 6 5
4
1 2 3 4 

Output:
1 9 2 8 3 7 4 6 5
1 4 2 3

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.