Skip to content

Commit c3efdaf

Browse files
committed
Time: 55 ms (48.39%), Space: 34.6 MB (40.27%) - LeetHub
1 parent 5ddac97 commit c3efdaf

File tree

1 file changed

+18
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)