class Solution {
public:
int hammingWeight(uint32_t n) {
int count=0;
for(int i=0;i<32;i++)
{
if(n&1)
count++;
n>>=1;
}
return count;
}
};
191. Number of 1 Bits
最新推荐文章于 2022-09-05 21:24:14 发布