38ms Python


  • 0
    G

    class Solution(object):
    def hammingDistance(self, x, y):
    count = 0
    binary = bin(x ^ y)[2:]
    for c in binary:
    if c == '1':
    count +=1
    return count


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.