414. Third Maximum Number

xiaoxiao2021-02-27  148

找第3个大的数

class Solution(object):

    def thirdMax(self, nums):         """         :type nums: List[int]         :rtype: int         """         nums = set(nums)         if len(nums) < 3:             return max(nums)         nums.remove(max(nums))         nums.remove(max(nums))

        return max(nums)

https://leetcode.com/problems/third-maximum-number/#/description

转载请注明原文地址: https://www.6miu.com/read-14718.html

最新回复(0)