My shortest go/golang solution


  • 0
    W

    func hammingDistance(x int, y int) int {
    nCount := 0
    for r := x ^ y; r != 0; r >>= 1 {
    if r&1 == 1 {
    nCount++
    }
    }
    return nCount
    }


Log in to reply
 

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