public class Solution {
public String largestNumber(int[] nums){
Integer[]in=new Integer[nums.length];
for (int i = 0; i < nums.length; i++) {
in[i]=nums[i];
}
Arrays.sort(in,new Compare());
StringBuilder sb = new StringBuilder();
for (int i = nums.length - 1; i >= 0; i--) {
sb.append(in[i]);
}
if(sb.charAt(0) == '0'){
return "0";
}
return sb.toString();
}
public class Compare implements Comparator<Integer> {
public int compare(Integer arg0, Integer arg1) {
String s1 = arg0.toString();
String s2 = arg1.toString() + arg1.toString();
while (s1.length() < s2.length()) {
s1 += s1;
}
while (s2.length() < s1.length()) {
s2 += s2;
}
return s1.compareTo(s2);
}
}
}