Bitwise operation is not accepted


#1

Can anyone tell why is it failing for large test cases but similar solution posted here is getting passed?

int Solution::cntBits(vector<int> &A) {
int n = A.size();
if(n == 0)
    return 0;
if(n ==  1)
    return 0;
    
int ret =0;
for(int i = 0 ; i < 32 ; i++)
{
    int ones = 0, zeroes = 0;
    for(int j = 0 ; j < n ; j++)
    {
        int temp = (A[j] >> i) & 1;
        if(temp)
            ones++;
        else
            zeroes++;
    }
    ret += (ones*zeroes*2);
    ret = ret%1000000007;
    
}
return ret%1000000007;
}