def product_exclude_itself(nums):
    """
    Compute the product of given array exclude itself

    :param nums: given array
    :type nums: list[int]
    :return: A long long array B and B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1]
    :rtype: list[int]
    """
    result = [1] * len(nums)

    # solve the left part (A[0] * ... * A[i-1]) first
    for i in range(1, len(nums)):
        result[i] = result[i - 1] * nums[i - 1]

    # solve the right part (A[i+1] * ... * A[n-1])
    temp = 1
    for i in range(len(nums) - 1, -1, -1):
        result[i] *= temp
        temp *= nums[i]

    return result