Given an integer array nums, return the largest product of any non-empty contiguous subarray. Pattern focus: Max product subarray. Track both the maximum and minimum product ending at each position because a negative number can flip the sign.
nums = integer array
maximum product of any contiguous subarray
Example 1:
Input:
nums = [2,3,-2,4]
Output:
6
Explanation:
The best subarray is [2,3].
Example 2:
Input:
nums = [-2,0,-1]
Output:
0
Explanation:
The subarray [0] gives the highest product.