Problem
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Now your job is to find the total Hamming distance between all pairs of the given numbers.
Example
1 | Input: 4, 14, 2 |
Solution1
Method: Backtracking
Time Complexity:
Space Complexity:
1 | class Solution: |
Solution2
Method: Bit Manipulation
Time Complexity: O(n logv)
Space Complexity:
1 | class Solution: |