My issue
not able solve this problem output is getting coorect but hidden test cases are failing
My code
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void solve() {
int n;
cin >> n;
vector<int> a(n);
unordered_set<int> seen;
int duplicates = 0;
// Read the array and track duplicates
for (int i = 0; i < n; i++) {
cin >> a[i];
if (seen.count(a[i]) > 0) {
duplicates++; // Count duplicates
} else {
seen.insert(a[i]); // Mark the element as seen
}
}
// The number of operations required is equal to the number of duplicates
cout << duplicates << '\n'; // Output the number of operations needed
}
int main() {
fastio
int T;
cin >> T; // Number of test cases
while (T--) {
solve(); // Process each test case
}
return 0;
}
Problem Link: Remove and Add Practice Coding Problem