package main
import (
"fmt"
)
func hammingDistance(x int, y int) int {
c := x ^ y
count := 0
for c != 0 {
count += 1
c = c&(c-1)
}
return count
}
func main() {
fmt.Println(hammingDistance(1,4))
}
Leetcode (go语言) 计算汉明距离
猜你喜欢
转载自blog.csdn.net/weixin_34050427/article/details/91031569
今日推荐
周排行