0
点赞
收藏
分享

微信扫一扫

[220301] Counting Bits

香小蕉 2022-03-11 阅读 122
class Solution:
    def countBits(self, n):

        res = []

        for i in range(n + 1):
            # format(i, 'b') --> convert an integer to a binary string without prefix
            res.append(format(i, 'b').count('1'))

        return res

 

举报

相关推荐

0 条评论