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

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

LeetCode: Hamming Distance

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

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黄石市| 安吉县| 南宫市| 固安县| 万州区| 泸溪县| 太仆寺旗| 出国| 崇仁县| 茶陵县| 禹城市| 灵川县| 元江| 牡丹江市| 安丘市| 六枝特区| 清丰县| 开阳县| 大理市| 青川县| 长泰县| 时尚| 绍兴市| 晴隆县| 铜陵市| 西和县| 扬州市| 体育| 榆树市| 湖南省| 浪卡子县| 萝北县| 卫辉市| 嘉祥县| 六盘水市| 兰坪| 桃江县| 双鸭山市| 县级市| 湘乡市| 琼结县|