One line solution in Python


  • -9
    H
    class Solution(object):
    def largestNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: str
        """
        return '0' if not any(nums) else "".join(sorted(map(str, nums), reverse=True, cmp=lambda s1, s2: int(s1+s2)-int(s2+s1))).lstrip('0')

Log in to reply
 

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