#include <algorithm> #include <vector> std::vector<int> vec; if (std::find(vec.begin(), vec.end(), key) == vec.end()) { // if key not in vec, add it vec.push_back(key); }