Maximum Product Subarray (Medium)
Problem Statement
Given an integer array, find the contiguous subarray (at least one number in it) that has the maximum product. Return this maximum product.
Examples
-
- Input: [2,3,-2,4]
- Expected Output: 6
- Justification: The subarray [2,3] has the maximum product of 6.
-
- Input: [-2,0,-1]
- Expected Output: 0
- Justification: The subarray [0] has the maximum product of 0.
-
- Input: [-2,3,2,-4]
- Expected Output: 48
- Justification: The subarray [-2,3,2,-4] has the maximum product of 48.
Try it yourself
Try solving this question here:
Python3
Python3
. . .