Practice Special Array With X Elements Greater Than or Equal X
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Special Array With X Elements Greater Than or Equal X
Problem Statement
You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x. Notice that x does not have to be an element in nums. Return x if the array is special, otherwise, return -1. It can be proven that if nums is special, the value for x is unique.
Source: Special Array With X Elements Greater Than or Equal X on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [3,5]
2
# Example 2
nums = [0,0]
-1
# Example 3
nums = [0,4,3,0,4]
3
Constraints
Related LeetCode Problems
Practice more problems similar to Special Array With X Elements Greater Than or Equal X.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.