414. Third Maximum Number
https://leetcode.com/problems/third-maximum-number
Python
class Solution:
def thirdMax(self, nums: List[int]) -> int:
sorted_nums = sorted(list(set(nums)))
if len(sorted_nums) < 3:
return max(sorted_nums)
result = None
for i in range(3):
if nums:
result = sorted_nums.pop()
return result