Python | Leetcode Python题解之第414题第三大的数
题目:
题解:
class Solution:def thirdMax(self, nums: List[int]) -> int:a, b, c = None, None, Nonefor num in nums:if a is None or num > a:a, b, c = num, a, belif a > num and (b is None or num > b):b, c = num, belif b is not None and b > num and (c is None or num > c):c = numreturn a if c is None else c