题目:
class Solution {
public:
int hammingWeight(uint32_t n) {
int result = 0;
for(int i=0;i<32;i++){
if(n&(1<<i)) result++; //利用按位与
}
return result;
}
};
标签:hammingWeight,15,Offer,二进制,个数,int
From: https://www.cnblogs.com/fly-smart/p/17677922.html