0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00

68. 0到n-1中缺失的数字

https://www.acwing.com/problem/content/submission/code_detail/7757230/
This commit is contained in:
Baoshuo Ren 2021-09-16 16:17:16 +08:00 committed by Baoshuo Ren
parent 32a72cdeb4
commit e63bc3ff36
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

13
AcWing/68/68.cpp Normal file
View File

@ -0,0 +1,13 @@
class Solution {
public:
int getMissingNumber(vector<int>& nums) {
set<int> s;
for (int i = 0; i <= nums.size(); i++) {
s.insert(i);
}
for (int i : nums) {
s.erase(i);
}
return *s.begin();
}
};