68. Arrange the array to the smallest number.
Title: Enter an array of positive integers, concatenate them into a number, and output the smallest of all the numbers that can be drained.
One.
For example, the input array {32, 321}, the output of these two can be ranked as the smallest number 32132.
Please give an algorithm to solve the problem, and prove that the algorithm
1 PackageCom.rui.microsoft;2 3 Importjava.util.Arrays;4 ImportJava.util.Comparator;5 6 Public classTest68_minimum {7 8 Public Static voidMain (string[] args) {9 int[] A = {3,2,123};TenTest68_minimum app =Newtest68_minimum (); OneString res =App.smallest (a); A System.out.println (res); - } - theString Smallest (int[] a) { -integer[] aux =NewInteger[a.length]; - for(inti = 0; i < a.length; i++){ -Aux[i] =A[i]; + } - +Arrays.sort (AUX,NewComparator<integer>() { A at @Override - Public intCompare (integer O1, integer o2) { - return("" + O1 + O2). CompareTo ("" + O2 +O1); - } - }); - inStringBuilder SB =NewStringBuilder (); - for(inti = 0; i < aux.length; i++){ to sb.append (Aux[i]); + } - returnsb.tostring (); the } *}
Microsoft algorithm 100 question 68 with the smallest number of arrays