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

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

191. Number of 1 Bits

2019-11-14 11:46:04
字體:
供稿:網(wǎng)友

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; }};
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 崇州市| 宁强县| 涞水县| 琼海市| 五家渠市| 湘西| 梁平县| 通许县| 玛沁县| 太谷县| 南溪县| 长子县| 浦县| 精河县| 雷波县| 龙川县| 建始县| 福建省| 阳谷县| 五寨县| 平乐县| 安泽县| 高清| 隆德县| 潢川县| 洪洞县| 克东县| 柳州市| 白河县| 翼城县| 康保县| 息烽县| 普兰县| 万山特区| 博乐市| 安远县| 缙云县| 横山县| 庐江县| 西充县| 招远市|