Given an integer array nums, return the largest product you can get from any non-empty contiguous subarray.
Input / output
nums: int[]Examples
nums = [2, 3, -2, 4] returns 6 because the best subarray is [2, 3].nums = [-2, 0, -1] returns 0 because every non-empty subarray has product -2, 0, or -1.nums = [-2, 3, -4] returns 24 because the whole array multiplies to 24.Constraints
1 <= nums.length <= 20000-10 <= nums[i] <= 10Edge cases
Target complexity
O(n) time and O(1) extra space.Hints
Follow-up Why is tracking only the current maximum product insufficient once negative numbers are allowed?