标签:mic inf compare i++ leetcode ++ 最小 return stringbu
方法:自定义排序:O(logn)
class Solution { public String minNumber(int[] nums) { String[] strs = new String[nums.length]; for(int i = 0; i < nums.length; i++) strs[i] = String.valueOf(nums[i]); Arrays.sort(strs, (x, y) -> (x + y).compareTo(y + x)); StringBuilder res = new StringBuilder(); for(String s : strs) res.append(s); return res.toString(); } }
标签:mic inf compare i++ leetcode ++ 最小 return stringbu
原文地址:https://www.cnblogs.com/oldby/p/12919568.html