반응형
leetcode.com/problems/product-of-array-except-self/
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
output = []
left = 1
right = 1
for i in range(len(nums)):
output.append(left)
left *= nums[i]
for i in range(len(nums)-1,-1,-1):
output[i] *= right
right *= nums[i]
return output
댓글