python accepted solution


  • 0
    Y
    class Solution(object):
        def countBits(self, num):
            """
            :type num: int
            :rtype: List[int]
            """
            r=[0]*(num+1)
            for i in range(1,len(r)):
                r[i]=r[i//2]+(1&i)
            return r
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.