Choose two different indices i and j that maximise (nums[i] - 1) * (nums[j] - 1) and return that maximum.
i
j
(nums[i] - 1) * (nums[j] - 1)
nums = [3,4,5,2]
12
Why
(5 - 1) * (4 - 1) = 12
nums = [1,5,4,5]
16
2 <= nums.length <= 500 1 <= nums[i] <= 10^3
Topics
Implement maxProduct in the editor and return the answer — printing it is never graded.
maxProduct
Problem 64 of 1146 in the arena