劍指offer: 二進制中1的個數 python 實現

題目 題目描述 輸入一個整數,輸出該數二進制表示中1的個數。其中負數用補碼錶示。web 解題思路 # -*- coding:utf-8 -*- class Solution: def NumberOf1(self, n): # write code here return bin(n & 0xffffffff).count('1')
相關文章
相關標籤/搜索