class Solution:
def thirdMax(self, nums: List[int]) -> int:
nums=list(dict.fromkeys(nums)) #to remove duplicates
nums.sort() #to easily navigate to the large numbers
if len(nums)<3:
return nums[-1] #if there is not 3 elements, preventing existence of a 3rd largest
else:
return nums[-3] #if there will exist a 3rd largest since n>=3