Skip to content

Commit 2f1de8d

Browse files
authored
Create 442.cpp
1 parent 793b951 commit 2f1de8d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

leetcode/cpp/Array/442.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
vector<int> findDuplicates(vector<int>& nums) {
4+
sort(nums.begin(),nums.end());
5+
vector<int> ans;
6+
for(int i=1;i<nums.size();i++)
7+
{
8+
if(nums[i]==nums[i-1])
9+
{
10+
ans.push_back(nums[i]);
11+
}
12+
}
13+
return ans;
14+
}
15+
};

0 commit comments

Comments
 (0)