Skip to content

Commit 2fa4efd

Browse files
authored
Create 1608-special-array-with-x-elements-greater-than-or-equal-x.js
1 parent daf0682 commit 2fa4efd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
const specialArray = function (nums) {
6+
nums.sort((a, b) => b - a)
7+
let i = 0
8+
while(i < nums.length && nums[i] >= i) {
9+
i++
10+
}
11+
if(nums[i - 1] < i) return -1
12+
return i
13+
};

0 commit comments

Comments
 (0)