values. For indices i < j < k, the value of the triple is
(values[i] - values[j]) * values[k]
Return the largest value over all such triples. If every triple has a negative value, return 0.values=[9, 4, 2, 8, 3] → 56
Indices (0, 2, 3) give (9 − 2) · 8 = 56, and nothing beats that.
values=[2, 5, 9] → 0
The only triple gives (2 − 5) · 9 = −27, which is negative, so the answer is 0.
values=[5, 1, 6, 3, 10] → 40
values=[9, 4, 2, 8, 3]
56
Run checks the first 3 tests in your browser. Submit checks all 124 tests on the server, hidden ones included.