```
class Solution(object):
def thirdMax(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
ninf = -float("inf")
firstMax = ninf
secondMax = ninf
thirdMax = ninf
if nums:
firstMax = max(nums) # O(n)
for i in range(len(nums)): # O(n)
m = max(secondMax,nums[i])
if m < firstMax:
secondMax = m
if secondMax == ninf:
secondMax = firstMax
for i in range(len(nums)): # O(n)
m = max(thirdMax,nums[i])
if m < secondMax:
thirdMax = m
if thirdMax == ninf:
thirdMax = firstMax
return thirdMax
```