Skip to content

Commit 89cdd7a

Browse files
authored
Create 1608. Special Array With X Elements Greater Than or Equal X (#490)
2 parents 79b0921 + 6bee1f1 commit 89cdd7a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public:
3+
int specialArray(vector<int>& nums) {
4+
sort(nums.begin(),nums.end());
5+
for(int i=1;i<=nums.size();i++){
6+
auto it=lower_bound(nums.begin(),nums.end(),i);
7+
if(nums.end()-it==i) return i;
8+
}
9+
return -1;
10+
}
11+
};

0 commit comments

Comments
 (0)