Skip to the code
cf.
+25 XP

#497 Largest Scale Multiplier Run

medium

An animation chains scale transforms, and factors[i] is the whole-number multiplier of step i. A negative factor flips the element.

Write largestProductRun(factors) that returns the largest product of a run of one or more consecutive factors.

Example 1

Input: factors = [3,2,-3,5]
Output: 6

The run [3, 2] gives 6. Adding -3 makes it negative.

Example 2

Input: factors = [-3,0,-2]
Output: 0

Every run with two or more factors includes the 0, and the single factors are -3, 0, and -2.

Constraints

  • 1 <= factors.length <= 15
  • -10 <= factors[i] <= 10
Saved in this browser

Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.

Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).