Three lines Python Solution


  • 0
    L
    class Solution(object):
        def countBits(self, num):
            ll = [0];i = -1
            while 2**i<num:i += 1;ll.extend([x+1 for x in ll])
            return ll[0:num+1]
    

Log in to reply
 

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