Please solve the programming task below using a self-contained code snippet in a markdown code block.

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given an integer array nums, return the sum of Hamming distances between all the pairs of the integers in nums.
 
Please complete the following python code precisely:
```python
class Solution:
    def totalHammingDistance(self, nums: List[int]) -> int:
```