2023-12-09 18:42:21 +08:00
< p > Given an integer array < code > nums< / code > , find a < span data-keyword = "subarray-nonempty" > subarray< / span > that has the largest product, and return < em > the product< / em > .< / p >
2022-03-27 20:56:26 +08:00
< p > The test cases are generated so that the answer will fit in a < strong > 32-bit< / strong > integer.< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:56:26 +08:00
< pre >
< strong > Input:< / strong > nums = [2,3,-2,4]
< strong > Output:< / strong > 6
< strong > Explanation:< / strong > [2,3] has the largest product 6.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:56:26 +08:00
< pre >
< strong > Input:< / strong > nums = [-2,0,-1]
< strong > Output:< / strong > 0
< strong > Explanation:< / strong > The result cannot be 2, because [-2,-1] is not a subarray.
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = nums.length < = 2 * 10< sup > 4< / sup > < / code > < / li >
< li > < code > -10 < = nums[i] < = 10< / code > < / li >
< li > The product of any prefix or suffix of < code > nums< / code > is < strong > guaranteed< / strong > to fit in a < strong > 32-bit< / strong > integer.< / li >
< / ul >