class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ return bin(n).count('1')
When execution: 16 ms, beat the 94.92% of all users in Python submission
Memory consumption: 11.7 MB, defeated 31.64% of users in all Python submission
——2019.10.10