MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / thirdMax

Method thirdMax

Array/ThirdMaximumNumbers.py:42–51  ·  view source on GitHub ↗

:type nums: List[int] :rtype: int

(self, nums)

Source from the content-addressed store, hash-verified

40"""
41class Solution(object):
42 def thirdMax(self, nums):
43 """
44 :type nums: List[int]
45 :rtype: int
46 """
47 nums = set(nums)
48 if len(nums) < 3:
49 return max(nums)
50
51 return sorted(nums, reverse=True)[2]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected