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 f34b332 commit 1691310Copy full SHA for 1691310
product-of-array-except-self/krokerdile.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def productExceptSelf(self, nums: List[int]) -> List[int]:
3
+ n = len(nums)
4
+ answer = [1] * n
5
+
6
+ # 1. 왼쪽 곱 저장
7
+ left_product = 1
8
+ for i in range(n):
9
+ answer[i] = left_product
10
+ left_product *= nums[i]
11
12
+ # 2. 오른쪽 곱을 곱해주기
13
+ right_product = 1
14
+ for i in reversed(range(n)):
15
+ answer[i] *= right_product
16
+ right_product *= nums[i]
17
18
+ return answer
0 commit comments