#include <iostream>
#include <vector>
using namespace std;
vector<int> findDup(int a[], int len) {
vector<int> ret;
for (int i = 0; i<len; i++) {
if(a[abs(a[i])] > 0) a[abs(a[i])] *= -1;
else ret.push_back(abs(a[i]));
}
return ret;
}
int main() {
int a[] = {1,3,2,2,1};
vector<int> vet;
vet = findDup(a, sizeof(a)/sizeof(a[0]));
for (int i:vet) cout<<i<<" ";
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdmVjdG9yPGludD4gZmluZER1cChpbnQgYVtdLCBpbnQgbGVuKSB7Cgl2ZWN0b3I8aW50PiByZXQ7Cglmb3IgKGludCBpID0gMDsgaTxsZW47IGkrKykgewoJCWlmKGFbYWJzKGFbaV0pXSA+IDApIGFbYWJzKGFbaV0pXSAqPSAtMTsKCQllbHNlIHJldC5wdXNoX2JhY2soYWJzKGFbaV0pKTsKCX0KCXJldHVybiByZXQ7Cn0KCmludCBtYWluKCkgewoJaW50IGFbXSA9IHsxLDMsMiwyLDF9OwoJdmVjdG9yPGludD4gdmV0OwoJdmV0ID0gZmluZER1cChhLCBzaXplb2YoYSkvc2l6ZW9mKGFbMF0pKTsKCWZvciAoaW50IGk6dmV0KSBjb3V0PDxpPDwiICI7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCglyZXR1cm4gMDsKfQ==