The list function in Python


  • 0
    K

    class Solution(object):
    def countBits(self, num):
    """
    :type num: int
    :rtype: List[int]
    """
    _list = []
    for i in xrange(num+1):

            binary = bin(i)
            _list.append(binary.count('1'))
        
        return _list

Log in to reply
 

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