Given an array & a value x, find if the array contains any 2 values whoes sum = x
Sigiloso
#include #include using namespace std; bool findIfSum(const vector &x, const int val) { vectory = x; sort(begin(y), end(y)); for (auto i = y.begin(); i != y.end(); ++i) { int diff = val - *i; if (diff < 0) return false; if (binary_search (i, y.end(), diff)) return true; } return false; }