Skip to content

Commit f38344b

Browse files
Time: 73 ms (57.98%), Space: 31 MB (21.22%) - LeetHub
1 parent 3f0124e commit f38344b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
vector<int> findErrorNums(vector<int>& nums) {
4+
vector<int> res;
5+
unordered_map<int,int> ump;
6+
for(auto i:nums)
7+
ump[i]++;
8+
for(auto i:ump){
9+
if(i.second==2){
10+
res.push_back(i.first);
11+
break;
12+
}
13+
}
14+
for(int i=1;i<=ump.size()+1;++i){
15+
if(ump.find(i)==ump.end()){
16+
res.push_back(i);
17+
break;
18+
}
19+
}
20+
return res;
21+
}
22+
};

0 commit comments

Comments
 (0)