Given an integer array nums, return the largest product of any non-empty contiguous subarray, with stronger stress on sign changes and zeros. Pattern focus: Max product subarray. The recurrence must keep the best positive and most negative running products simultaneously.
nums = integer array
maximum product of any contiguous subarray
Example 1:
Input:
nums = [-1,-3,-10,0,60]
Output:
60
Explanation:
The single element 60 is the best product.
Example 2:
Input:
nums = [6,-3,-10,0,2]
Output:
180
Explanation:
The subarray [6,-3,-10] has product 180.