from typing import List


class Solution:

    def productExceptSelf(self, nums: List[int]) ->List[int]:
        answer = []
        p = 1
        for i in range(len(nums)):
            answer.append(p)
            p *= nums[i]
        p = 1
        for i in range(len(nums) - 1, -1, -1):
            answer[i] *= p
            p *= nums[i]
        return answer


def test():
    solution = Solution()
    assert solution.productExceptSelf([1, 2, 3, 4]) == [24, 12, 8, 6]
    assert solution.productExceptSelf([-1, 1, 0, -3, 3]) == [0, 0, 9, 0, 0]

f865c8a8397828ce72d85f897db6e513d155b434
<mask token>


class Solution:
    <mask token>


<mask token>

<mask token>


class Solution:

    def productExceptSelf(self, nums: List[int]) ->List[int]:
        answer = []
        p = 1
        for i in range(len(nums)):
            answer.append(p)
            p *= nums[i]
        p = 1
        for i in range(len(nums) - 1, -1, -1):
            answer[i] *= p
            p *= nums[i]
        return answer


<mask token>

<mask token>


class Solution:

    def productExceptSelf(self, nums: List[int]) ->List[int]:
        answer = []
        p = 1
        for i in range(len(nums)):
            answer.append(p)
            p *= nums[i]
        p = 1
        for i in range(len(nums) - 1, -1, -1):
            answer[i] *= p
            p *= nums[i]
        return answer


def test():
    solution = Solution()
    assert solution.productExceptSelf([1, 2, 3, 4]) == [24, 12, 8, 6]
    assert solution.productExceptSelf([-1, 1, 0, -3, 3]) == [0, 0, 9, 0, 0]

from typing import List


class Solution:

    def productExceptSelf(self, nums: List[int]) ->List[int]:
        answer = []
        p = 1
        for i in range(len(nums)):
            answer.append(p)
            p *= nums[i]
        p = 1
        for i in range(len(nums) - 1, -1, -1):
            answer[i] *= p
            p *= nums[i]
        return answer


def test():
    solution = Solution()
    assert solution.productExceptSelf([1, 2, 3, 4]) == [24, 12, 8, 6]
    assert solution.productExceptSelf([-1, 1, 0, -3, 3]) == [0, 0, 9, 0, 0]
