Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
class Solution(object):
def thirdMax(self, nums):
nums=sorted(set(nums),reverse=True)
return max(nums) if len(nums)<3 else min(nums[0:3])
This solution's time complexity is more than O(n) though space complexity is O(1)
set - O(n)
sorted - O(n log n)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.