# 乘积最大子数组

<p>给你一个整数数组 <code>nums</code>&nbsp;，请你找出数组中乘积最大的连续子数组（该子数组中至少包含一个数字），并返回该子数组所对应的乘积。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre><strong>输入:</strong> [2,3,-2,4]
<strong>输出:</strong> <code>6</code>
<strong>解释:</strong>&nbsp;子数组 [2,3] 有最大乘积 6。
</pre>

<p><strong>示例 2:</strong></p>

<pre><strong>输入:</strong> [-2,0,-1]
<strong>输出:</strong> 0
<strong>解释:</strong>&nbsp;结果不能为 2, 因为 [-2,-1] 不是子数组。</pre>


## template

```python

class Solution:
    def maxProduct(self, nums: List[int]) -> int:
        if len(nums) == 0:
            return 0

        length = len(nums)

        dp = [[0] * 2 for _ in range(length)]

        dp[0][0] = nums[0]
        dp[0][1] = nums[0]

        for i in range(1, length):

            if nums[i] > 0:
                dp[i][0] = min(nums[i], dp[i - 1][0] * nums[i])
                dp[i][1] = max(nums[i], dp[i - 1][1] * nums[i])
            else:
                dp[i][0] = min(nums[i], dp[i - 1][1] * nums[i])
                dp[i][1] = max(nums[i], dp[i - 1][0] * nums[i])

        res = dp[0][1]
        for i in range(1, length):
            res = max(res, dp[i][1])
        return res

```

## 答案

```python

```

## 选项

### A

```python

```

### B

```python

```

### C

```python

```