mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 16:12:47 +08:00
10 lines
157 B
Go
10 lines
157 B
Go
package leetcode
|
|
|
|
func hammingDistance(x int, y int) int {
|
|
distance := 0
|
|
for xor := x ^ y; xor != 0; xor &= (xor - 1) {
|
|
distance++
|
|
}
|
|
return distance
|
|
}
|