You are given an integer array nums.
Your task is to find a contiguous subarray within the array that has the maximum product and return that product.
Notes:
• A subarray consists of one or more consecutive elements.
• The product of a single-element subarray is the value of that element itself.
• The result will always fit in a 32-bit signed integer.
Input: nums = [3, -1, 4, -2, 5]
Output: 120
Explanation:
The subarray [3, -1, 4, -2, 5] gives the largest product = 3 × (-1) × 4 × (-2) × 5 = 120.
Input: nums = [-1, -3, -10, 0, 60]
Output: 60
Explanation:
The subarray [60] has the maximum product 60.
Input: nums = [-2, -3, 0, -2, -40]
Output: 80
Explanation:
The subarray [-2, -40] has the product 80
Accepted:
Submission: