public class Solution {
// you need to treat n as an unsigned value
public int hammingWeight(int n) {
int res = 0;
for(int i = 1; i <= 32 ; i++){
if((n&1) == 1){
res++;
}
n = n >> 1;
}
return res;
}
}
04-14
179
09-29
1106