Given an integer array nums, find a contiguous non-empty subarray within the array that has the largest product, and return the product.
def maxProduct(self, nums: List[int]) -> int:
curmin = curmax = ans = nums[0]
for num in nums[1:]:
# If num is zero, the following will set everything to zero
t = (num, num * curmin, num * curmax)
curmin = min(t)
curmax = max(t)
ans = max(ans, curmax)
return ans