public int hammingWeight(int n) {
int count = 0;
for(int i=0;i<32;i++){
if((n & 1) == 1) count++;
n = n >>> 1;
}
return count;
}
LeetCode--Number Of 1 bits
最新推荐文章于 2023-07-08 03:04:01 发布
public int hammingWeight(int n) {
int count = 0;
for(int i=0;i<32;i++){
if((n & 1) == 1) count++;
n = n >>> 1;
}
return count;
}