#-*- 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])
相关文章
- 12-10【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
- 12-10[leetcode]Maximum Product Subarray @ Python
- 12-10[LeetCode]题解(python):136-Single Number
- 12-10LeetCode in Python 559. Maximum Depth of N-ary Tree
- 12-10Python3解leetcode Single Number
- 12-10Leetcode 104 Maximum Depth of Binary Tree python
- 12-10【LeetCode】137. Single Number II 解题报告(Python)
- 12-10【leetcode❤python】 Maximum Depth of Binary Tree
- 12-10[leetcode]Binary Tree Maximum Path Sum @ Python
- 12-10Leetcode: 1937. Maximum Number of Points with Cost