class Solution {
public:
int hammingWeight(uint32_t n) {
int ans = 0;
while(n){
ans++;
n &= n-1;
}
return ans;
}
};
leetcode 191. Number of 1 Bits
最新推荐文章于 2025-07-29 19:45:28 发布