46 ms python beat 100.00%


  • 1
    C
    class Solution(object):
        def hammingDistance(self, x, y):
            """
            :type x: int
            :type y: int
            :rtype: int
            """
            diff, res = x ^ y, 0
            while diff > 0:
                diff &= (diff - 1)
                res += 1
            return res
    '''

Log in to reply
 

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