Description
You are given an array nums of non-negative integers. nums is special if there exists a number x such that exactly x numbers in nums are >= x. Return x or -1.
Examples
Input:
nums = [3,5]Output:
2Explanation:
2 elements >= 2.
Input:
nums = [0,0,4,4,4]Output:
3Explanation:
There are exactly 3 elements that are >= 3 (the three 4s), so x = 3
Input:
nums = [1,2,3,4,5,6]Output:
4Explanation:
There are exactly 4 elements that are >= 4 (4, 5, 6, and one more), so x = 4
Constraints
- •
1 ≤ nums.length ≤ 100