Simple Golang solution 3ms


  • 0
    R
    func hammingDistance(x int, y int) int {
        xor:= x ^ y
        count := 0
        var j uint
        for j=0;  j< 32; j++ {
            count+=(xor >> j) & 1
        }
        return count
    }
    
    

Log in to reply
 

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