题解 | #把数组排成最小的数#
把数组排成最小的数
http://www.nowcoder.com/practice/8fecd3f8ba334add803bf2a06af1b993
import java.util.ArrayList; import java.lang.*; import java.util.*; public class Solution { public String PrintMinNumber(int [] numbers) { if(numbers.length==0||numbers==null) return ""; String[] s =new String[numbers.length]; for(int i=0;i<numbers.length;i++){ s[i]=String.valueOf(numbers[i]); } Arrays.sort(s,(s1,s2)->(s1+s2).compareTo(s2+s1)); StringBuilder sb = new StringBuilder(); for(String ss:s){ sb.append(ss); } return sb.toString(); } }