Total Hamming Distance

Medium · Bit Manipulation · about 15 minutes

Asked at Meta, Apple, Google.

Given an integer array nums of non-negative values, return the sum of the Hamming distances between all pairs of elements.