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 7fb126b commit b9c6be1Copy full SHA for b9c6be1
product-of-array-except-self/radiantchoi.py
@@ -0,0 +1,20 @@
1
+class Solution:
2
+ def productExceptSelf(self, nums: List[int]) -> List[int]:
3
+ reduced = 1
4
+ zeroes = 0
5
+
6
+ for num in nums:
7
+ if num != 0:
8
+ reduced *= num
9
+ else:
10
+ zeroes += 1
11
12
+ result = []
13
14
15
+ if num == 0:
16
+ result.append(0 if zeroes - 1 > 0 else reduced)
17
18
+ result.append(0 if zeroes else reduced // num)
19
20
+ return result
0 commit comments