All submissions for this problem are available.
There are two friends,Atul and Sanjay. Atul asked Sanjay to arrange an integer array to in a special manner such as a1>=a2<=a3>=a4<=a5...... . Sanjay found that he can do this easily for an array with small size but for big size array he can't do this.Could you help Sanjay to sort out this problem. NOTE : If there are more than one ways, return the one thats lexicographically smallest.
The first line of the input contains a single integer T, denoting the number of test cases. The first line of each testcase contains one number N : the length of the array in the testcase. The second line of each testcase contains N separated integers , representing array .
The output of each testcase contains N separated integers , representing arranged array .
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 10^6
- 1 ≤ A[i] ≤ 10^6
Input: 1 4 1 2 3 4 Output: 2 1 4 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.