Skip to content

Commit c733486

Browse files
committed
cpp
1 parent 4c2df97 commit c733486

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+
vector<int>A;
5+
6+
for(int i=0;i<nums.size();i++){
7+
int j=nums[i];
8+
j=abs(j)-1;
9+
if(nums[j]<0){
10+
A.push_back(j+1);
11+
}
12+
else{
13+
nums[j]=nums[j]* (-1);
14+
}
15+
}
16+
return A;
17+
}
18+
};

0 commit comments

Comments
 (0)