FunctionRacerProblemsRace

Maximum Product of Two Elements

BeginnerSorting and searchingPython, JavaScript, TypeScript, Java, C++

Choose two different positions i and j of nums and compute (nums[i] - 1) * (nums[j] - 1). Return the largest value this can have.

Example 1

nums [3,4,5,2]
returns 12

(5-1) * (4-1) = 12.

Example 2

nums [1,5,4,5]
returns 16

(5-1) * (5-1) = 16.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Sorting and searching problems