```
class Solution {
public:
vector<int> findDuplicates(vector<int>& nums) {
int size = nums.size();
vector<int> result;
int temp[size+1] = { 0 };
for (int i = 0; i < size; ++i)
{
if (++temp[nums[i]] == 2)
{
result.push_back(nums[i]);
}
}
return result;
}
};
```