1730. Special Array With X Elements Greater Than or Equal X
My accepted Python solution to LeetCode problem 1730, Special Array With X Elements Greater Than or Equal X, running in 7ms.
- Difficulty: Easy
- Python
- Runtime 7ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 7ms, memory 17.2MB, accepted 2025-12-31.
class Solution:
def specialArray(self, nums: List[int]) -> int:
n = len(nums)
for x in range(n + 1):
count = sum(1 for num in nums if num >= x)
if count == x:
return x
return -1