Number of 1 bits solution
unknown
c_cpp
2 years ago
242 B
6
Indexable
class Solution {
public:
int hammingWeight(uint32_t n) {
int count = 0;
while(n!= 0){
if(n&1){
count++;
}
n = n>>1;
}
return count;
}
};Editor is loading...
Leave a Comment