Bit Manipulation? Short python solution


  • 0
    2

    Each time you're just adding a first '2' to the previous list.

    def countBits(self, num):
            bits = [0, 1]
            while len(bits) < num+1:
                bits += [1 + bit for bit in bits]
            return bits[:num+1]
    
    

Log in to reply
 

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