Maximum product subarray
Mediumdynamic programmingarray
Return the largest product of a contiguous non-empty part of nums.
Example 1
Input: nums = [2,3,-2,4] Output: 6
Example 2
Input: nums = [-2,0,-1] Output: 0
Constraints
- 1 ≤ nums.length ≤ 2·10⁴
- -10 ≤ nums[i] ≤ 10
- Every product fits in 32 bits
Submit checks your solution against 9 tests, including hidden ones.
/**
* @param {int[]} nums
* @return {int}
*/
function maxProduct(nums) {
}