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

首頁 > 學院 > 開發設計 > 正文

LeetCode: Hamming Distance

2019-11-09 20:24:17
字體:
來源:轉載
供稿:網友

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;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 铁力市| 临武县| 枝江市| 崇左市| 杨浦区| 且末县| 天峻县| 大化| 内黄县| 娄底市| 屏东市| 房山区| 雷州市| 沽源县| 招远市| 嘉祥县| 阜阳市| 拜泉县| 余姚市| 逊克县| 盐山县| 平江县| 如皋市| 申扎县| 福州市| 长海县| 江达县| 青龙| 四平市| 梅州市| 广宁县| 隆回县| 柯坪县| 丰原市| 高碑店市| 怀安县| 鄂州市| 嘉峪关市| 湘乡市| 怀仁县| 桦川县|