#include <iostream>
#include <vector>
#include <unordered_map>
bool containsUniqueValues(const std::vector<int>& vec) {
// Create a map to store the frequency of each number
std::unordered_map<int, int> frequency;
// Count occurrences of each number in the array
for (int num : vec) {
frequency[num]++;
}
// Check if any number appears only once
for (const auto& entry : frequency) {
if (entry.second == 1) {
return true; // Found a unique value
}
}
return false; // No unique value found
}
int main() {
// Example array
std::vector<int> vec = {1, 2, 3, 4, 2, 1, 5, 3, 5, 6};
if (containsUniqueValues(vec)) {
std::cout << "The vector contains unique values.\n";
} else {
std::cout << "The vector does not contain any unique values.\n";
}
return 0;
}
/*
run:
The vector contains unique values.
*/