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 c79c692 commit ef71c9fCopy full SHA for ef71c9f
product-of-array-except-self/yayyz.py
@@ -0,0 +1,16 @@
1
+class Solution:
2
+ # prefix, postfix probelm :(
3
+ def productExceptSelf(self, nums: List[int]) -> List[int]:
4
+ output = [1] * len(nums)
5
+
6
+ prefix = 1
7
+ for i in range(len(nums)):
8
+ output[i] = prefix
9
+ prefix *= nums[i]
10
11
+ postfix = 1
12
+ for i in range(len(nums) -1, -1, -1):
13
+ output[i] *= postfix
14
+ postfix *= nums[i]
15
16
+ return output
0 commit comments