# 191. Number of 1 Bits

Write a function that takes the binary representation of a positive integer and returns the number of set bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)).

### Thoughts

* This one is basically identical to [2220](https://lc.sweezy.io/2220) kekw
    

### Solution

```java
class Solution {
    public int hammingWeight(int n) {
        return Integer.bitCount(n);
    }
}
```

**Time Complexity:** O(1)  
**Space Complexity:** O(1)

### Conclusion

umm, these bit manipulation ones are pretty easy. I suppose I should find a way to calculate this myself and not use a built in function to do it. I can see providing this answer in an interview and being asked to provide a correct answer to it.
