题目 代码 这里面有个神奇的规律。 0 0->1 0->1->1->2 0->1->1->2->1->2->2->3 class Solution: def countBits(self, num): """ :type num: int :rtype: List[int] """ result = [0,1] temp = [1] while len(result) < num+2: temp = temp + [i+1 for i in temp] result += temp return result[:num+1]