scores. Find an integer x such that exactly x elements of the array are greater than or equal to x. The value x itself does not have to appear in the array.
It can be shown that if such an x exists, it is unique. Return it, or -1 if there is none.scores=[9, 1, 4, 3] → 3
Exactly three values are at least 3: 9, 4 and 3.
scores=[1, 1] → -1
Both values are at least 1, which is two rather than one; none is at least 2. No x fits.
scores=[0, 0, 5] → 1
Only one value, 5, is at least 1.
scores=[9, 1, 4, 3]
3
Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.