[LeetCode] Third Maximum Number (Python)
2024. 3. 3. 10:40ㆍ자료구조
class Solution:
def thirdMax(self, nums: List[int]) -> int:
nums = set(nums)
nums = sorted(nums, reverse=True)
if len(nums) < 3:
answer = nums[0]
else:
answer = nums[2]
return answer
'자료구조' 카테고리의 다른 글
[LeetCode] Design Circular Queue (Python) (0) | 2024.03.05 |
---|---|
[LeetCode] Find All Numbers Disappeared in an Array (Python) (0) | 2024.03.03 |
[LeetCode] Height Checker (Python) (0) | 2024.03.03 |
[LeetCode] Sort Array By Parity (Python) (0) | 2024.02.29 |
[LeetCode] Move Zeroes (Python) (0) | 2024.02.29 |