2
So in the question we want to find out the3
number of difference of bits between each pair4
so in the brute force we will iterate over the vector5
and for every pair we will calculate the Hamming distance6
the Hamming distance will be calculated by taking XOR between the two elements7
and then finding out the number of ones in the XOR of those two elements8
the intuition behind this method is that XOR will contain 1's at those places9
where the corresponding bits of elements x & y are different10
therefore we will add this count15
int hammingDistance(int x, int y) {27
int totalHammingDistance(vector<int> &nums) {29
for (int i = 0; i < nums.size() - 1; i++) {30
for (int j = i + 1; j < nums.size(); j++) {31
ans += hammingDistance(nums[i], nums[j]);