Ctrl K

Two Picks, Minus One

Easy
You are given an array of positive integers values. Pick two elements at different indices i and j and compute (values[i] − 1) · (values[j] − 1). Return the largest value this expression can take.
Example 1
values=[6, 2, 9, 4] → 40

Take 9 and 6: (9 − 1) · (6 − 1) = 8 · 5 = 40.

Example 2
values=[1, 7] → 0

There is no choice here: (1 − 1) · (7 − 1) = 0.

Example 3
values=[4, 8, 8, 3] → 49
Constraints
  • 2 ≤ len(values) ≤ 500
  • 1 ≤ values[i] ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsMedals and Places EasyAverage of the Best Five EasyThe Dimmest Rows EasyBest Picks in Order EasyThree-Drink Dispenser Easy
loading Python…
Input
values=[6, 2, 9, 4]
Expected
40

Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.