Special Array With X Elements
nums is special if there is a number x such that exactly x items of nums are greater than or equal to x. (x does not have to be in nums.)
Return that x, or -1 if nums is not special. When it is special, x is always unique.
Example 1
nums [3,5]
returns 2
x = 2: exactly two items (3 and 5) are at least 2.
Example 2
nums [0,0]
returns -1
No x works, so -1.
Constraints
1 <= len(nums) <= 300 <= nums[i] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.