Simple 5 line code


#1

int Solution::diffPossible(const vector &a, int k) {
unordered_map<int,int>mp;
for(int i=0;i<a.size();i++)
{
if(mp.count(k+a[i])||mp.count(a[i]-k))return true;
mp[a[i]]++;
}
return false;
}