Hamming Distance

Easy · Bit Manipulation · about 5 minutes

Asked at Meta, Adobe, Amazon, Apple.

The Hamming distance between two integers is the number of bit positions at which they differ. Given two non-negative integers x and y, return their Hamming distance.