C++ solution using Unordered_map


#1

Commenint Solution::diffPossible(const vector &A, int B)
{
unordered_map<int,int>map;
int i;
int x=A[i]+B,y=A[i]-B;
map[x]=1;
map[y]=1;
for(i=1;i<A.size();i++)
{
x=A[i];
if(map.find(x)!=map.end())
{
return 1;
}
x=A[i]+B;
y=A[i]-B;
map[x]=1;
map[y]=1;
}
return 0;
}
t body goes here.