Look at this very short solution using XOR . Y am I getting partial marks? Using Python


class Solution:
# @param A : list of integers
# @return an integer

def f(self,x,y):
    for i in bin(x^y).replace('0b',''):
    return count

def cntBits(self, A):
    for i in range(len(A)-1):
        for j in range(i+1, len(A)):
            ans+=self.f(A[i], A[j])
    return 2*ans


I did the same in C++ but look at the complexity it’s O(n^2)
Optimize it and it is accepting.