values. Choose three elements at different indices so that their product is as large as possible, and return that product.
Keep in mind that the numbers may be negative.values=[-8, -5, 1, 2, 4] → 160
Two negatives make a positive: (−8) · (−5) · 4 = 160, which beats 1 · 2 · 4 = 8.
values=[-4, -3, -2, -1] → -6
All numbers are negative, so any product of three is negative too. The one closest to zero is (−3) · (−2) · (−1) = −6.
values=[0, 6, 2, 3] → 36
values=[-8, -5, 1, 2, 4]
160
Run checks the first 3 tests in your browser. Submit checks all 114 tests on the server, hidden ones included.