Peak Product

HardAcc. 64.2%
+50 XP 30

Multiplicative Max

Given an array, find the maximum product of any contiguous slice.

The Assignment

Your function receives nums.

  1. For simplicity, use nested loops to check all possible subarrays.
  2. Track the maxProduct.
  3. Print the Result.

01EXAMPLE 1

Input[2, 3, -2, 4]
Output6

Explanation: Subarray [2, 3] product is 6.

Constraints

  • Handle negative numbers.
ArraysAlgorithms
JavaScript
Loading...
1 Hidden

Input Arguments

nums[2,3,-2,4]

Expected Output

6

Click RUN to test your solution