simple python code 45ms


  • -1
    N

    class Solution(object):
    def hammingDistance(self, x, y):
    """
    :type x: int
    :type y: int
    :rtype: int
    """
    count=0
    x=int(bin(x).replace('0b',''))
    y=int(bin(y).replace('0b',''))
    count=str(x+y).count('1')
    return count


Log in to reply
 

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