Skip to content

Commit b01af14

Browse files
authored
Create 1464-maximum-product-of-two-elements-in-an-array.py
1 parent d7f2044 commit b01af14

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def maxProduct(self, nums: List[int]) -> int:
3+
high = secondHigh = 0
4+
for n in nums:
5+
if n > high:
6+
secondHigh = high
7+
high = n
8+
else:
9+
secondHigh = max(n, secondHigh)
10+
return (high - 1) * (secondHigh - 1)

0 commit comments

Comments
 (0)