class Solution {
public:
int hammingWeight(uint32_t n) {
int ret = 0;
while (n != 0)
{
ret += n & 1;
n = n >> 1;
}
return ret;
}
};
public:
int hammingWeight(uint32_t n) {
int ret = 0;
while (n != 0)
{
ret += n & 1;
n = n >> 1;
}
return ret;
}
};
评论
发表评论