Hi all,

My algorithm is to check the bit at the right most of the number by AND-ing with 1, then shift that number by 1 bit to the right. Not sure why it doesn't work for MAX INT case. Thanks!

```
public int hammingWeight(int n) {
int count = 0;
while (n > 0){
if ((n & 1) == 1){
count++;
}
n = n >> 1;
}
return count;
}
```