1133. Largest Unique Number
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : October 01, 2024
Last updated : October 01, 2024
Related Topics : Array, Hash Table, Sorting
Acceptance Rate : 70.6 %
# Slow but funny oneliner
class Solution:
def largestUniqueNumber(self, nums: List[int]) -> int:
return max(nums + [-1], key=lambda x: (-Counter(nums + [-1])[x], x))
class Solution:
def largestUniqueNumber(self, nums: List[int]) -> int:
nums.sort()
while nums :
curr = nums.pop()
if not nums or nums[-1] != curr :
return curr
while nums and nums[-1] == curr :
nums.pop()
return -1