class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ return bin(n).count('1')
执行用时 :16 ms, 在所有 Python 提交中击败了94.92%的用户
内存消耗 :11.7 MB, 在所有 Python 提交中击败了31.64%的用户
——2019.10.10