Study Notes
Problem editorialmedium

Total Hamming distance

Sum the differing bits over every pair. The trick is not faster pair comparison — it is refusing to look at pairs at all, and counting one bit column at a time.

18 min read·time O(n)·space O(1)
Per-bit columnsCounting contributionLoop inversion