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 e43f14a commit b81d6edCopy full SHA for b81d6ed
maximum-product-subarray/hu6r1s.py
@@ -0,0 +1,8 @@
1
+class Solution:
2
+ def maxProduct(self, nums: List[int]) -> int:
3
+ result = nums[0]
4
+ min_prod = max_prod = 1
5
+ for num in nums:
6
+ min_prod, max_prod = min(min_prod * num, max_prod * num, num), max(min_prod * num, max_prod * num, num)
7
+ result = max(max_prod, result)
8
+ return result
0 commit comments