Return the largest product of a contiguous, non-empty run of nums. Values can be negative or zero.
The tests keep the product small for long lists (the values are -1, 0 and 1 there), and use values from -2 to 2 for short lists.
Example 1
Input:
max_product_subarray([2, 3, -2, 4])
Output:
6
The run [2, 3] has product 6.
Example 2
Input:
max_product_subarray([-2, 0, -1])
Output:
0
The best is 0; neither -2 nor -1 alone is better.
1 <= len(nums) <= 2 * 10**5-2 <= nums[i] <= 2No results yet
Run your code to check it against the examples, or submit to run every test.