剑指offer python版 二进制中1的个数

def aa (n):
    if not n:
        return False
    
    ret=0
    while n:
        ret +=1
        n=n&n-1
    return ret


print(aa(38))
    

猜你喜欢

转载自www.cnblogs.com/xzm123/p/9849324.html
今日推荐