Program to find the maximum product subarray in a given array is discussed here. Given an array of integers as input, the task is to find the subarray from the given input array whose product is maximum.
For example, consider the given array
Input: {-1, -3, -10, 60,0}
Output: 1800
Sub-array : {-3, -10, 60}
Product of the sub-array = -3 * -10 * 60 = 1800
Program to find the maximum product subarray in the given array is given below.
@@coding::1@@
Time complexity: O(n)
Recommended Programs