香小蕉

关注

[220301] Counting Bits

香小蕉

关注

阅读 122

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

老北京的热干面 147 0 0

豆丁趣

338. Counting Bits**

豆丁趣 105 0 0

伊人幽梦

Bits

伊人幽梦 135 0 0

是波波呀

Flip Bits

是波波呀 25 0 0

booksmg2014

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

booksmg2014 15 0 0

四月Ren间

lintcode: Flip Bits

四月Ren间 151 0 0

杰森wang

lintcode:Update Bits

杰森wang 126 0 0

我阿霆哥

Leetcode: Reverse Bits

我阿霆哥 85 0 0

火热如冰

UESTC 491 Tricks in Bits

火热如冰 142 0 0

小亦同学321

190. Reverse Bits

小亦同学321 31 0 0

精彩评论(0)

0 0 举报