import java.util.Arrays;
import java.util.Comparator;
public class Solution {
public String PrintMinNumber(int [] numbers) {
if(numbers.length==0) return "";
String[] num = new String[numbers.length];
for(int i=0;i<numbers.length;i++)
num[i] = numbers[i]+"";
Arrays.sort(num,new Comparator<String>()
{
public int compare(String num1,String num2)
{
return (num1+num2).compareTo(num2+num1);
}
});
StringBuffer ss = new StringBuffer("");
for(String v:num)
ss.append(v);
return ss.toString();
}
}
45、把数组排成最小的数
最新推荐文章于 2020-11-26 12:29:12 发布