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 870ef38 commit 43ba99cCopy full SHA for 43ba99c
product-of-array-except-self/kayden.py
@@ -0,0 +1,18 @@
1
+# 시간복잡도: O(N)
2
+# 공간복잡도: out 제외시 O(1)
3
+class Solution:
4
+ def productExceptSelf(self, nums: List[int]) -> List[int]:
5
+ n = len(nums)
6
+ out = [1] * n
7
+
8
+ prod = 1
9
+ for i in range(n - 1):
10
+ prod *= nums[i]
11
+ out[i + 1] *= prod
12
13
14
+ for i in range(n - 1, 0, -1):
15
16
+ out[i - 1] *= prod
17
18
+ return out
0 commit comments