My issue
please help me why codechef is bombarding me with wrong answer when my code seems correct gives same sample output and very similar to accepted submissions
My code
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
if(a[i]>0){
for (int j = i+1; j < n; j++) {
if (a[i] == a[j]&& i!=j) {
a[i] = a[j] = -1;
}
}
}
}
for (int i = 0; i < n; i++) {
if (a[i] != -1) {
cout << a[i] << " ";
}
}
cout << endl;
}
return 0;
}
Problem Link: MISSP Problem - CodeChef