191. Number of 1 Bits

class Solution(object):
    def hammingWeight(self, n):
        """
        :type n: int
        :rtype: int
        """
        count = 0
        for i in range(32):
            if (n>>i)%2 == 1:
                count += 1
        return count

blogroll

social