Pythonic Solution, Beat 99%, Easy Understand


  • 0
    S
    class Solution(object):
        def thirdMax(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            nums = sorted(list(set(nums)))
            if len(nums) < 3: return max(nums)
            else: return nums[-3]
    

    Obvious? Go Pythonic


Log in to reply
 

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