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

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

【LeetCode】461. Hamming Distance【E】【90】

2019-11-08 19:25:34
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(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.思路很簡(jiǎn)單,先轉(zhuǎn)成二進(jìn)制,然后計(jì)算異或,然后看一共有多少個(gè)1 就是結(jié)果了 
class Solution(object):    def hammingDistance(self, x, y):        return ((bin(x ^ y)[2:])).count('1')        """        :type x: int        :type y: int        :rtype: int        """
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 车致| 茂名市| 从化市| 额尔古纳市| 呼图壁县| 调兵山市| 德阳市| 渝北区| 华阴市| 商城县| 凯里市| 吴旗县| 金昌市| 弥渡县| 于田县| 宾川县| 武宁县| 巴彦县| 平泉县| 玉门市| 泌阳县| 太原市| 额尔古纳市| 河曲县| 施甸县| 丰城市| 辽源市| 安化县| 吐鲁番市| 沐川县| 神木县| 岐山县| 南华县| 邯郸县| 汤阴县| 石景山区| 寿宁县| 思茅市| 措美县| 萨嘎县| 杂多县|