【LeeCode 2017/06/13】 461. Hamming Distance
1 class Solution {
2 public:
3 int hammingDistance(int x, int y) {
4 int count = 0;
5 for (int n = x ^ y; n; n >>= 1){
6 if ((n & 1) == 1)
7 count++;
8 }
9 return count;
10 }
11 };
2 public:
3 int hammingDistance(int x, int y) {
4 int count = 0;
5 for (int n = x ^ y; n; n >>= 1){
6 if ((n & 1) == 1)
7 count++;
8 }
9 return count;
10 }
11 };
posted on 2017-06-13 10:16 Wurq 閱讀(152) 評論(0) 編輯 收藏 引用 所屬分類: 【LeeCode 每日N題】
