152. Maximum Product Subarray
Practice Maximum Product Subarray for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Return the largest product of a non-empty contiguous subarray of nums.
Example
nums = [2,3,-2,4] -> 6 ([2,3])
nums = [-2,0,-1] -> 0
Constraints
- 1 <= nums.length <= 2 * 10^4
- -10 <= nums[i] <= 10
- The product of any subarray fits in a 32-bit signed integer