All submissions for this problem are available.Prof. Virus has developed a special kind of magnet that oppose the odd number and attracts even number. The magnet has special kind of property that higher the number that feel more attraction or repulsion as compare to lower number. for example number 4 will be more attracted than number 2 and number 3 will be more opposed than number 1. In the presences of the magnet, the numbers of the array will get swapped automatically according to the forces of attraction or repulsion they feel. now Prof. Virus want to show his magnet power to his students. but your friend Rancho want to do some prank with prof. with arranging numbers in such a way that magnet can not change the position of any elements. But Rancho don't have any coding skill so he want your help. can you help him to do some prank with Prof. Note - the magnet will be applied on starting of array. ----o [ $A_1$,$A_2$,…,$A_N$] ###Input: - First line will contain T number of testcases. Then the testcases follow. - first line of each test case contains size of array N - Next line contains N space separated integers $A_1$,$A_2$,…,$A_N$ . ###Output: For each testcase, output in a single line N space separated integers arranged according to above problem. ###Constraints - $1 \leq T \leq 100$ - $1 \leq N \leq 10^5$ - $0 \leq Ai \leq 10^6$ - the sum of N over all test cases is $N \leq 10^6$ ###Sample Input: - 2 - 4 - 4 1 2 3 - 4 - 2 6 4 8 ###Sample Output: - 4 2 1 3 - 8 6 4 2 ###EXPLANATION: Test case 1. the magnet will be applied on starting of list so 1 will be opposed and 2 will be attracted towards the magnet . so they will be swapped. but you can arrange the arrray like this [ 4,2,1,3] and there is no effect of magnet.
|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, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.