Simple & easy solution

interview-questions
Tags: #<Tag:0x00007f2445a117e0>

#1

Using map to lookup for A[j]

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

return 0;

}