192ms, beat 100% python 4 line solution


  • 1
    L
    class Solution(object):
    def countBits(self, num):
        """
        :type num: int
        :rtype: List[int]
        """
        ret = [0]
        while num > len(ret) - 1:
            ret += [a + 1 for a in ret]
        return ret[0 : num + 1]

Log in to reply
 

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