Loading...
Loading...
Loading...
A scanner gives a list of whole-number factors, some negative or zero. Choose a run of consecutive factors, at least one long, with the largest product. Print the product.
Example 1
Input
2 3 -2 4
Output
6
2 x 3 = 6 is the best run.
Example 2
Input
-2 0 -1
Output
0
Try the problem first. Open one hint at a time.
A negative factor can turn the smallest product into the largest, so track two values.
For each factor keep the largest and the smallest product of a run ending there.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor