def count_bits_via_hamming_weight(num: int) -> list[int]:
    """Compute the number of 1's in the binary representation of every number in the range [0, num].

    Complexity:
        N = num + 1
        Time: O(n) (NUM_BITS_PER_INT * N since for each number we have to right-shift bits until the number is 0)
            note: NUM_BITS_PER_INT is assumed to be constant
        Space: O(n) (to store the result list)

    Args:
        num: unsigned integer

    Returns: an array of the number of 1's in the binary representation of every number in the range [0, num]

    Examples:
        >>> count_bits_via_hamming_weight(-1)
        []
        >>> count_bits_via_hamming_weight(2)
        [0, 1, 1]
        >>> count_bits_via_hamming_weight(5)
        [0, 1, 1, 2, 1, 2]

    """
    ## EDGE CASES ##
    if num < 0:
        return []

    """ALGORITHM"""
    ## INITIALIZE VARS ##
    # DS's/res
    num_bits_in_nums_in_range_0_to_num = []

    for num in range(num + 1):
        hamming_weight = 0
        while num != 0:
            hamming_weight += num & 1
            num >>= 1
        num_bits_in_nums_in_range_0_to_num.append(hamming_weight)

    return num_bits_in_nums_in_range_0_to_num