1464. Maximum Product of Two Elements in an Array
On This Page
class Solution:
def maxProduct(self, nums: List[int]) -> int:
a = b = 0
for v in nums:
if v > a:
a, b = v, a
elif v > b:
b = v
return (a - 1) * (b - 1)