mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 16:38:47 +00:00
68. 0到n-1中缺失的数字
https://www.acwing.com/problem/content/submission/code_detail/7757230/
This commit is contained in:
parent
32a72cdeb4
commit
e63bc3ff36
13
AcWing/68/68.cpp
Normal file
13
AcWing/68/68.cpp
Normal 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();
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user