题目描述
Given an array of numbers form 0 to 9 of size N. Your task is to rearrange elements of the array such that after combining all the elements of the array number formed is maximum.
Example 1:
Input:
N = 5
A[] = {9, 0, 1, 3, 0}
Output:
93100
Explanation:
Largest number is 93100 which
can be formed from array digits.
Example 2:
Input:
N = 3
A[] = {1, 2, 3}
Output:
321
Your Task:
You don't need to read input or print anything. Your task is to complete the function MaxNumber() which takes the array A[] and its size N as inputs and returns a single line a string denoting the largest number that can be achieved by rearranging the elements of the array.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
1 <= N <= 10^{7}
0 <= A_{i }<= 9
输入格式
见题面
输出格式
见题面