国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

LeetCode: Hamming Distance

2019-11-10 18:03:21
字體:
供稿:網(wǎng)友

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 ≤ xy < 231.

Example:

Input: x = 1, y = 4Output: 2Explanation:1   (0 0 0 1)4   (0 1 0 0)       ↑   ↑The above arrows point to positions where the corresponding bits are different.

Subscribe to see which companies asked this question.

int hammingDistance(int x, int y) {        int d = 0;    for (int i = 0; i < 32; ++i)    {        d += (x & 1) ^ (y & 1);        x >>= 1;        y >>= 1;    }        return d;}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 鄂托克前旗| 偏关县| 南木林县| 满城县| 台南市| 济源市| 若羌县| 江达县| 满洲里市| 和平区| 孙吴县| 无为县| 祁阳县| 苏尼特左旗| 饶河县| 光山县| 宝鸡市| 革吉县| 宜宾县| 霞浦县| 米泉市| 报价| 泰州市| 甘谷县| 平昌县| 利川市| 呼伦贝尔市| 教育| 宜丰县| 长海县| 淄博市| 榆中县| 左贡县| 东阳市| 专栏| 牡丹江市| 锡林浩特市| 康平县| 枣强县| 安宁市| 乌什县|