179. Largest Number

class Solution {
    public String largestNumber(int[] nums) {
        String[] arr=new String[nums.length];
        for(int i=0;i<nums.length;i++)
            arr[i]=Integer.toString(nums[i]);
        Arrays.sort(arr, (a, b)->{return new String(b+a).compareTo(a+b);});
        if(arr[0].charAt(0) == '0')
            return "0";        
        String res="";
        for(String a:arr)
            res+=a;
        return res;
    }
}

  

posted @ 2017-10-25 04:35  Weiyu Wang  阅读(92)  评论(0编辑  收藏  举报