Third Maximum Number Solutions in PythonNumber 414Difficulty EasyAcceptance 30.5%Link LeetCodeOther languages C++, GoSolutionsPython solution by haoel/leetcodedef thirdMax(self, nums): if len(set(nums)) < 3: return max(nums) first = second = third = float('-inf') for n in nums: if n > first: third = second second = first first = n elif second < n < first: third = second second = n elif third < n < second: third = n return thirddef thirdMax(self, nums): if len(set(nums)) < 3: return max(nums) first = second = third = float('-inf') for n in nums: if n > first: third = second second = first first = n elif second < n < first: third = second second = n elif third < n < second: third = n return third