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

This solution time exceeded on n == 0. But it returns the correct answer immediately on my computer?