for (int i = 0; i < arr.size(); i++) { if (seen[arr[i]]) { arr[i] = 0; } else { seen[arr[i]] = true; } }
}
int main() { int N; std::cout << "Enter the size of the array: "; std::cin >> N;
std::vector<int> arr(N); std::cout << "Enter the elements of the array: "; for (int i = 0; i < N; i++) { std::cin >> arr[i]; } removeDuplicates(arr); std::cout << "Resulting array after removing duplicates: "; for (int num : arr) { std::cout << num << " "; } return 0;
void removeDuplicates(std::vector& arr) {
for (int i = 0; i < arr.size(); i++) {std::unordered_map<int, bool> seen;
if (seen[arr[i]]) {
arr[i] = 0;
} else {
seen[arr[i]] = true;
}
}
}
int main() {
std::vector<int> arr(N);int N;
std::cout << "Enter the size of the array: ";
std::cin >> N;
std::cout << "Enter the elements of the array: ";
for (int i = 0; i < N; i++) {
std::cin >> arr[i];
}
removeDuplicates(arr);
std::cout << "Resulting array after removing duplicates: ";
for (int num : arr) {
std::cout << num << " ";
}
return 0;
}