Last active
February 12, 2019 20:53
-
-
Save bcowell/3243a1888e36de66cf8d38744edcde55 to your computer and use it in GitHub Desktop.
hamming-distance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hammingDistance(self, x, y): | |
xor = bin(x^y) | |
return xor.count("1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution for leetcode 461. Hamming Distance