Problem
Return the sum of the Hamming distances (the number of differing bit positions) between every pair of numbers in nums.
Example 1
- Input
- nums = [4, 14, 2]
- Output
- 6
Example 2
4 = 0100, 14 = 1110, 2 = 0010
Example 3
d(4, 14) + d(4, 2) + d(14, 2) = 2 + 2 + 2
Example 4
- Input
- nums = [4, 14, 4]
- Output
- 4
Constraints
1 <= nums.length <= 10^40 <= nums[i] <= 10^9The answer fits in a 32-bit integer.