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 9ae3cf9 commit 1392d95Copy full SHA for 1392d95
maximum-product-subarray/printjin-gmailcom.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def maxProduct(self, nums):
3
+ max_prod = min_prod = result = nums[0]
4
+ for n in nums[1:]:
5
+ temp_max = max(n, max_prod * n, min_prod * n)
6
+ min_prod = min(n, max_prod * n, min_prod * n)
7
+ max_prod = temp_max
8
+ result = max(result, max_prod)
9
+ return result
0 commit comments