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

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

191. Number of 1 Bits

2019-11-14 11:42:28
字體:
來源:轉載
供稿:網友

Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).

For example, the 32-bit integer ’11’ has binary rePResentation 00000000000000000000000000001011, so the function should return 3.

class Solution {public: int hammingWeight(uint32_t n) { int cnt = 0; while(n){ n = n & (n - 1); ++cnt; } return cnt; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 出国| 枞阳县| 邓州市| 芒康县| 花垣县| 阿尔山市| 云阳县| 怀集县| 南岸区| 汝州市| 齐齐哈尔市| 克拉玛依市| 大同县| 康保县| 都江堰市| 横山县| 金坛市| 天镇县| 神池县| 萍乡市| 安顺市| 桐城市| 从化市| 巴中市| 墨竹工卡县| 青神县| 惠来县| 临澧县| 泸州市| 蓝山县| 习水县| 孟津县| 阿巴嘎旗| 柯坪县| 阳曲县| 淅川县| 长岛县| 津市市| 安庆市| 辽阳市| 青海省|