Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.26 KB

_1133. Largest Unique Number.md

File metadata and controls

51 lines (36 loc) · 1.26 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : October 01, 2024

Last updated : October 01, 2024


Related Topics : Array, Hash Table, Sorting

Acceptance Rate : 70.6 %


Solutions

Python

# 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