Problem statement
You are given an array and asked for the run of neighbouring values with the largest product. Negatives are allowed, so the sign of the running product matters.
The run must be contiguous and must take at least one value.
Examples
Input[2, 3, -2, 4]
Output6
The run 2, 3 multiplies to 6; the 4 alone cannot beat it after the negative.
Input[-2, -3, -1]
Output6
Two negatives multiply to 6, and the third turns it back to -6.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing