Two line solution


  • 0
    2

    Well. You might say that it is not clear.

    class Solution(object):
    def largestNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: str
        """
        num_str = [str(i) for i in nums]
        num_str.sort(cmp=lambda x, y: 1 if x + y < y + x else -1)
    
        return str(eval(''.join(num_str)))

Log in to reply
 

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