Java三行代码解法
class Solution {
public String largestNumber(int[] nums) {
Integer[] ns = Arrays.stream(nums).boxed().toArray(Integer[]::new);
Arrays.sort(ns, (a, b) -> ("" + b + a).compareTo("" + a + b));
return Arrays.stream(ns).mapToInt(x -> x).sum() == 0 ? "0" : Arrays.stream(ns).map(Object::toString).collect(Collectors.joining(""));
}
}