The Lost Number
All submissions for this problem are available.
The legendary Sherlock Holmes needs your help in solving a case. He has been trying to solve the case of The Lost Number for a long time and using his exceptional skills, has been able to discover all N parts of the number. He also knows that the Lost Number is the arrangement of these N parts, that results in the numerically maximum number.
Since he is very busy with other cases, he needs you to use your coding skills to help him find The Lost Number. Given N numbers K1 K2 K3…Kn, output the biggest number that can be formed by joining these N numbers.
First line of the input contains the number of test cases T.
For each test case there are 2 lines of input-
The first line contains an integer N.
The second line contains N space separated numbers Ki.
For each test case output a single line containing the maximum number that can be formed.
Input: 3 3 4 1 8 2 231 942 2 59 542 Output: 841 942231 59542 Explanation for the second test case: 231 and 942 can have 2 possible arrangements 231942 and 942231. Since 942231>231942, the correct answer is 942231.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, 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, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions