values. For any three 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, 5, 3] → 35
The index triple (0, 2, 3) gives (9 − 2) · 5 = 35, and nothing beats it.
values=[2, 4, 8] → 0
The only triple gives (2 − 4) · 8 = −16 < 0, so the answer is 0.
values=[6, 1, 10, 1, 7] → 63
values=[9, 4, 2, 5, 3]
35
Run checks the first 3 tests in your browser. Submit checks all 116 tests on the server, hidden ones included.