Java Lambda 1 line


  • 0
    L
    public class Solution {
        public String largestNumber(int[] nums) {
            String result = Arrays.stream(nums).mapToObj(num->String.valueOf(num)).sorted((a,b)->(b+a).compareTo(a+b)).collect(Collectors.joining());
            return result.charAt(0) == '0' ? "0" : result;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.