Skip to content

Commit 55f5548

Browse files
committed
Time: 119 ms (21.87%), Space: 44.6 MB (19.20%) - LeetHub
1 parent e79d6bd commit 55f5548

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
vector<int> findDuplicates(vector<int>& nums) {
4+
vector<int> ans;
5+
unordered_map<int,int> mp;
6+
for(int i : nums){
7+
mp[i]++;
8+
}
9+
for(auto i : mp){
10+
if(mp[i.first]==2) ans.push_back(i.first);
11+
}
12+
return ans;
13+
}
14+
};

0 commit comments

Comments
 (0)