def hammingDistance(self, x, y): return list(bin(x ^ y)[2:]).count('1')
bin returns a string that starts with
0b (hence the
Good solution, but [2:] is not necessary, as we only care "1".
def hammingDistance(self, x, y):
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.