class Solution {
public:
int hammingWeight(uint32_t n) {
int count=0;
while(n!=0)
{
if(n%2==1)
{
count++;
}
n/=2;
}
return count;
}
};
leetCode191Number of 1 Bits
最新推荐文章于 2020-11-03 21:33:20 发布