leetcode 461: Hamming Distance
2017-01-03 18:54
330 查看
要求:求两个数之间的汉明距
public int hammingDistance(int x, int y) {
int count = 0;
while (x != 0 || y != 0) {
if (x % 2 != y % 2)
count++;
x = x / 2;
y = y / 2;
}
return count;
}
public int hammingDistance(int x, int y) {
int count = 0;
while (x != 0 || y != 0) {
if (x % 2 != y % 2)
count++;
x = x / 2;
y = y / 2;
}
return count;
}
相关文章推荐
- leetcode 461 Hamming Distance C++
- 刷题的日常[Leetcode]——461)Hamming Distance and 476)Number complement
- leetcode(461) Hamming Distance 简单题
- LeetCode461 Hamming Distance java The Hamming distance between two integers is the number osoluotion
- LeetCode 461: Hamming Distance
- LeetCode@Bit_461_Hamming_Distance
- LeetCode 477: Total Hamming Distance
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- [LeetCode] Total Hamming Distance 全部汉明距离
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- leetcode 477 Total Hamming Distance
- Leetcode Total Hamming Distance 477
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- Leetcode:Hamming Distance一些小结
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- Leetcode Hamming Distance
- [LeetCode]Total Hamming Distance(Java)
- LeetCode: Hamming Distance
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- LeetCode Hamming Distance