香小蕉

关注

[220301] Counting Bits

香小蕉

关注

阅读 127

2022-03-11

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

 

相关推荐

老北京的热干面

338. Counting Bits

老北京的热干面 148 0 0

豆丁趣

338. Counting Bits**

豆丁趣 106 0 0

伊人幽梦

Bits

伊人幽梦 139 0 0

是波波呀

Flip Bits

是波波呀 29 0 0

booksmg2014

FFmpeg源码:skip_bits、skip_bits1、show_bits函数分析

booksmg2014 19 0 0

四月Ren间

lintcode: Flip Bits

四月Ren间 155 0 0

杰森wang

lintcode:Update Bits

杰森wang 129 0 0

我阿霆哥

Leetcode: Reverse Bits

我阿霆哥 86 0 0

fbd4ffd0717b

leetcode - Number of 1 Bits

fbd4ffd0717b 52 0 0

小亦同学321

190. Reverse Bits

小亦同学321 31 0 0

精彩评论(0)

0 0 举报