1608. Special Array With X Elements Greater Than or Equal X

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1608

class Solution:
    def specialArray(self, nums: List[int]) -> int:
        nums.sort()
        n = len(nums)
        for x in range(1, n + 1):
            cnt = n - bisect_left(nums, x)
            if cnt == x:
                return x
        return -1