from typing import *
from queue import PriorityQueue


class Solution:
    def thirdMax(self, nums: List[int]) -> int:
        nums, maxV = list(set(nums)), 0
        q = PriorityQueue()
        for each in nums:
            maxV = each if each > maxV else maxV
            q.put(-each)

        rtn = 0
        for i in range(3):
            if q.empty():
                return maxV
            rtn = -q.get()
        return rtn


if __name__ == '__main__':
    s = Solution()
    print(s.thirdMax([1,2,2,5,3,5]))
