We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8175937 commit 915c79cCopy full SHA for 915c79c
product-of-array-except-self/mandoolala.py
@@ -0,0 +1,14 @@
1
+from typing import List
2
+
3
+class Solution:
4
+ def productExceptSelf(self, nums: List[int]) -> List[int]:
5
+ answer = [1] * len(nums)
6
+ left_product = 1
7
+ for i in range(len(nums) - 1):
8
+ left_product *= nums[i]
9
+ answer[i + 1] *= left_product
10
+ right_product = 1
11
+ for i in range(len(nums) - 1, 0, -1):
12
+ right_product *= nums[i]
13
+ answer[i - 1] *= right_product
14
+ return answer
0 commit comments