class Solution(object):
    def thirdMax(self, nums):
        first, second, third = None, None, None
        for num in nums:
            if num in [first, second, third]:
                continue

            if not first or num > first:
                third = second
                second = first
                first = num
            elif not second or num > second:
                third = second
                second = num
            elif not third or num > third:
                third = num
        return third if third != None else first
s = Solution()
nums =[2]
print(s.thirdMax(nums))
