【leetcode❤python】 414. Third Maximum Number

#-*- coding: UTF-8 -*-
#l1 = ['1','3','2','3','2','1','1']
#l2 = sorted(sorted(set(l1),key=l1.index,reverse=False),reverse=True)
class Solution(object):
    def thirdMax(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if nums==[]:return []
        nums=sorted(sorted(set(nums),key=nums.index),reverse=True)
        if len(nums)>=3:
            return nums[2]
        else:return nums[0]

sol=Solution()
print sol.thirdMax([1, 2])

上一篇:Krypton Factor


下一篇:IOS开发 多线程编程 - NSOperationQueue