191. Number of 1 Bits

来源:互联网 发布:快递查询源码 编辑:程序博客网 时间:2024/06/03 16:14
class Solution {public:    int hammingWeight(uint32_t n) {        int count = 0;        while (n) {            if(n & 1)                ++count;            n >>= 1;        }        return count;    }};

原创粉丝点击