题解 | #最大数#
最大数
http://www.nowcoder.com/practice/fc897457408f4bbe9d3f87588f497729
import java.util.*; import java.util.stream.Collectors; public class Solution { /** * 最大数 * @param nums int整型一维数组 * @return string字符串 */ public String solve (int[] nums) { // write code here String res = Arrays.stream(nums).mapToObj(String::valueOf).sorted(((o1, o2) -> (o2 + o1).compareTo(o1 + o2))).collect(Collectors.joining()); if(res.startsWith("0")){ return "0"; }else { return res; } } }