#K95942. Form the Largest Number
Form the Largest Number
Form the Largest Number
You are given an array of non-negative integers. Your task is to arrange these numbers such that they form the largest possible number when concatenated together. For example, given the numbers [10, 2, 9], the largest number formed is 9210.
In more formal terms, given an array (A = [a_1, a_2, \dots, a_n]), you need to find a permutation (\pi) of indices (1,2,\dots,n) such that the number formed by concatenating (a_{\pi(1)}a_{\pi(2)}\dots a_{\pi(n)}) is maximized.
Note: If the resulting number has leading zeroes (i.e. all numbers are 0), output a single "0".
inputFormat
The input begins with a single integer (T) on the first line, indicating the number of test cases. Each test case is described in two lines. The first line of each test case contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated non-negative integers.
outputFormat
For each test case, output a single line containing the largest number that can be formed by concatenating the given numbers.## sample
3
3
10 2 9
4
3 30 34 5 9
2
1 0
9210
9534330
10
</p>