标签:tar pre ems log esc tco not des oat
https://leetcode.com/problems/third-maximum-number/#/description
class Solution(object): def thirdMax(self, nums): """ :type nums: List[int] :rtype: int """ # if len(nums) == 0: # return None # elif len(nums) < 3: # return max(nums) #else: v = [float(‘-inf‘), float(‘-inf‘), float(‘-inf‘)] for num in nums: if num not in v: if num > v[0]: v = [num, v[0],v[1]] elif num > v[1]: v = [v[0], num, v[1]] elif num > v[2]: v = [v[0], v[1], num] if float(‘-inf‘) in v: return max(nums) return v[2]
标签:tar pre ems log esc tco not des oat
原文地址:http://www.cnblogs.com/prmlab/p/6971500.html