Why it is getting wrong for [96,96,7,81,2,13]


#1

int Solution::hammingDistance(const vector &A) {
int count=0;
int n=0;
int a=0;
int d;
int c;
int x=1;
int y;
int g;
int w=1;
int flag=1;
vector st;
for(int l=0;l<A.size()-1;l++)
{
if(A[l] == A[l+1])
{
flag=0;
}
else
{
flag=1;
break;
}
}
if(flag==0)
{
return 0;
}
else{
for(int i=0;i<A.size();i++)
{
if(A[i] == 1 || A[i] == 0)
{
st.push_back((A[i]));
}
else
{
int b=0;
int o=A[i];
while(o!=1)
{
n=o%2;
a=a+(pow(10,b)*n);
o=o/2;
b++;
}
a=a+(pow(10,b)1);
st.push_back(a);
}
}
for(int j=0;j<st.size()-1;j++)
{
for(int k=j+1;k<st.size();k++)
{
if(st[j]>st[k])
{
g=st[j];
y= st[k];
while(g!=0)
{
x=g%10;
g=g/10;
w=y%10;
y=y/10;
if(abs(x-w)==1)
{
count=count+1;
}
}
}
if(st[j]<st[k])
{
y=st[j];
g= st[k];
while(g!=0)
{
x=g%10;
g=g/10;
w=y%10;
y=y/10;
if(abs(x-w)==1)
{
count=count+1;
}
}
}
}
}
count=(count
2)%1000000007;
return(count);
}
}