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 5cbe348 commit 74bb692Copy full SHA for 74bb692
product-of-array-except-self/Sung-Heon.py
@@ -0,0 +1,14 @@
1
+class Solution:
2
+ def productExceptSelf(self, nums: List[int]) -> List[int]:
3
+ n = len(nums)
4
+ answer = [1] * n
5
+ left_product = 1
6
+ for i in range(n):
7
+ answer[i] = left_product
8
+ left_product *= nums[i]
9
+ right_product = 1
10
+ for i in range(n - 1, -1, -1):
11
+ answer[i] *= right_product
12
+ right_product *= nums[i]
13
+
14
+ return answer
0 commit comments