[LeetCode]461. Hamming Distance
来源:互联网 发布:优化驱动器有什么好处 编辑:程序博客网 时间:2024/05/16 10:03
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Given two integers x and y, calculate the Hamming distance.
Note:
0 ≤ x, y < 2^31.
My solution
class Solution{public: int hammingDistance(int x, int y){ int diff = x ^ y; int count = 0; //bitCount while(diff != 0){ count +=diff % 2; diff /= 2; } return count; }}
0 0
- LeetCode 461. Hamming Distance
- 【Leetcode】461. Hamming Distance
- LeetCode 461. Hamming Distance
- LeetCode - 461. Hamming Distance
- LeetCode-461. Hamming Distance
- 【LeetCode】 461. Hamming Distance
- Leetcode-461. Hamming Distance
- Leetcode 461. Hamming Distance
- LeetCode--461. Hamming Distance
- 461. Hamming Distance [LeetCode]
- [LeetCode]461. Hamming Distance
- leetcode 461. Hamming Distance
- Leetcode 461. Hamming Distance
- LeetCode 461. Hamming Distance
- 【LeetCode】461. Hamming Distance
- LeetCode-461. Hamming Distance
- LeetCode | 461. Hamming Distance
- [LeetCode]461.Hamming Distance
- Linux下oracle数据库启动和关闭操作
- 计财部算数
- 【java】Tomcat启动报错 无法启动报错
- 2017,新的开始
- CF764 C. Timofey and a tree(dfs序+线段树)
- [LeetCode]461. Hamming Distance
- The hierarchy of the type is inconsistent错误
- 「The Most Important」浅谈JSP表单Post方式中文乱码问题
- 技术之旅
- 编程模拟自然(九):元胞自动机
- 肿瘤标志物检测一般有哪些项目
- android获得手机上应用的图标、应用名、包名
- 六角填数全排列
- [LeetCode]1. Two Sum