my python


  • 0
    H
    class Solution(object):
        def hammingDistance(self, x, y):
            """
            :type x: int
            :type y: int
            :rtype: int
            """
            res = bin(x^y)
            t = 0
            for i in range(len(res)):
                if res[i]=='1':
                    t += 1
            return t
    

Log in to reply
 

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