golang bit solution


  • 0
    Z
    func hammingDistance(x int, y int) int {
        f := x ^ y;
        ret := 0;
        for (f > 0) {
            f &= f-1
            ret ++
        }
        return  ret;
    }
    

Log in to reply
 

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