Write a program in C to find the Maximum Product Subarray

Posted by Crniranjanraj under Others on 10/5/2015 | Points: 10 | Views : 2673 | Status : [Member] | Replies : 0
Given an array that contains both positive and negative integers, find the product of the maximum product sub array. Expected Time complexity is O(n) and only O(1) extra space can be used.

Examples:

Input: arr[] = {6, -3, -10, 0, 2}
Output: 180 // The subarray is {6, -3, -10}

Input: arr[] = {-1, -3, -10, 0, 60}
Output: 60 // The subarray is {60}

Input: arr[] = {-2, -3, 0, -2, -40}
Output: 80 // The subarray is {-2, -40}





Responses

(No response found.)

Login to post response