C++ soln of the question


#1

int Solution::diffPossible(const vector &v, int k) {
map<int,int> map;
int n=v.size();
for(int i=0;i<n;i++){
if(map[v[i]]==true){
return 1;
}
else{
map[v[i]-k]=true;
map[v[i]+k]=true;
}
}
return 0;
}
.