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

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

LeetCode: Hamming Distance

2019-11-09 20:03:34
字體:
供稿:網(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;}


上一篇:solr5.5+tomcate7部署

下一篇:poj1922

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 库伦旗| 南安市| 淮阳县| 栾川县| 洛隆县| 宜川县| 辽宁省| 彭泽县| 安龙县| 柘城县| 张北县| 泽库县| 兴文县| 漳平市| 陵川县| 商南县| 长沙市| 运城市| 平果县| 乡宁县| 冷水江市| 吉林市| 周口市| 长宁区| 舟山市| 连州市| 西华县| 容城县| 都兰县| 西宁市| 大姚县| 红原县| 漳州市| 喀喇| 贡嘎县| 肇源县| 岳西县| 湘西| 永靖县| 囊谦县| 大竹县|