nlog(n)复杂度
把数组排成最小的数
http://www.nowcoder.com/questionTerminal/8fecd3f8ba334add803bf2a06af1b993
import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; public class Solution { public String PrintMinNumber(int [] numbers) { if(numbers==null || numbers.length==0) return ""; int n = numbers.length; String [] nums = new String[n]; for(int i=0;i<n;i++){ nums[i] = numbers[i]+""; } Arrays.sort(nums,new Comparator<String>(){ public int compare(String o1,String o2){ return (o1+o2).compareTo(o2+o1); } }); String res = ""; for(String i : nums){ res+=i; } return res; }重写排序Array.sort()方法,由于底层为合并排序算法,复杂度为nlog(n)