Unordered Set C++ solution


#1
int Solution::diffPossible(const vector<int> &A, int B) {
    unordered_set<int> uset;
    for(int i=0;i<A.size();i++)
    {
        if(uset.find(A[i]-B)!=uset.end() || uset.find(A[i]+B)!=uset.end())
        {
            return 1;
        }
        else
        {
            uset.insert(A[i]);
        }
    }
    return 0;
}

#2

Man, you already used O(nlogn), still used a hash.
You could have done it without hash after sorting it.