One-dimensional Dynamic Programming
130 / 170One-dimensional Dynamic ProgrammingLesson 6 of 11About 42 min
If a bad value can become good, you have to carry it too.
This carries a single running best, the way the sum version does. Type the two values it prints, separated by a single space.
def largest_run_product_broken(values): best = running = values[0] for value in values[1:]: running = max(value, running * value) best = max(best, running) return best print(largest_run_product_broken([2, 3, -2, 4]), largest_run_product_broken([-2, 3, -4]))Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.