← 返回 bytedance 的题目列表Maximum Product Subarray
类型:online_judge
Maximum Product Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest product and return the product.
Input
One line of space-separated integers representing the array nums.
Output
A single integer: the maximum product over all contiguous subarrays.
Constraints
1 <= len(nums) <= 2 * 10^5
-10 <= nums[i] <= 10
Examples
Example 1
Input:
2 3 -2 4
Output:
6
Example 2
Input:
-2 0 -1
Output:
0
Example
Input
2 3 -2 4
Output
6