C++ O(nlog2(maxval))


#1
int Solution::hammingDistance(const vector<int> &A) {
    int n=A.size(),ans=0,c=0,m=log2(*max_element(A.begin(),A.end()));
    for(int i=0;i<=m+1;i++){
        int num=0;
        for(int j=0;j<n;j++){
            if((A[j]>>i)&1)
                num++;
        }
        ans=(ans+(num*(n-num))%((int)1e9+7))%((int)1e9+7);
    }
    return (ans*2)%((int)1e9+7);
}

#2

Not working, It’s giving wrong answer