#K59852. Largest Integer Concatenation
Largest Integer Concatenation
Largest Integer Concatenation
You are given a list of non-negative integers. Your task is to arrange these integers such that they form the largest possible integer when concatenated together.
More formally, given an array \( A = [a_1, a_2, \dots, a_n] \), you need to find a permutation \( \pi \) of the indices such that the concatenated number \( a_{\pi(1)}a_{\pi(2)} \dots a_{\pi(n)} \) is maximized. If the resulting number has leading zeros (e.g. all elements are zero), output should be "0".
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a single integer \( n \) (the number of integers).
- The second line contains \( n \) non-negative integers separated by spaces.
outputFormat
Output the largest integer (as a string) that can be formed by concatenating the given numbers. The output should be written to stdout.
## sample2
10 2
210