Example with negative
Input
nums = [2, 3, -2, 4]
Output
6
Subarray [2,3] gives product 6, which is maximal.
Full lesson preview
Compute the maximum product obtainable from a contiguous subarray.
Problem statement
Task
Examples
Input
nums = [2, 3, -2, 4]
Output
6
Subarray [2,3] gives product 6, which is maximal.
Input format
Output format
Constraints
Samples
Input
nums = [-2, 0, -1]
Output
0
Maximum product achievable is 0 (single element subarray [0]).