Clean and small C++ solution with unordered_set


#1
int Solution::diffPossible(const vector<int> &A, int k) {
    unordered_set<int> s;
    for (auto x:A) {
        if(s.count(x-k) || s.count(x+k))
            return true;
        s.insert(x);
    }
    return false;
}