Problem :

https://leetcode.com/problems/product-of-array-except-self/


My Solution :

class Solution:
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
n = len(nums)
ret = [1 for _ in range(n)]
for i in range(1, n):
ret[i] = nums[i-1] * ret[i-1]
a = nums[-1]
for j in range(n-2, -1, -1):
ret[j] *= a
a *= nums[j]
return ret