[algogeeks] Re: Maximum Product Contiguous Subarray

2007-04-26 Thread Lego Haryanto
I'm not even sure about my "log" comments, ... please disregard, sorry. On 4/26/07, Lego Haryanto <[EMAIL PROTECTED]> wrote: > > For negative numbers, ... why can't we log the absolute value and then > negate it of course? > > We should also assume if the data contains zeroes, though. This probab

[algogeeks] Re: Maximum Product Contiguous Subarray

2007-04-26 Thread Lego Haryanto
For negative numbers, ... why can't we log the absolute value and then negate it of course? We should also assume if the data contains zeroes, though. This probably has to be handled differently. On 4/26/07, Balachander <[EMAIL PROTECTED]> wrote: > > > Hi > > Think thats not, possible > > Is ur

[algogeeks] Re: Maximum Product Contiguous Subarray

2007-04-26 Thread Balachander
Hi Think thats not, possible Is ur soln : this way Arr : a[1 ...n] New Arr = newRR[ loga[i] .log[an] ] and Finding the max sum.. If so it ca be done as OLog is not defined for negative numbers .. Bala On Apr 26, 9:24 am, Arunachalam <[EMAIL PROTECTED]> wrote: > Multiplication can be convert

[algogeeks] Re: Maximum Product Contiguous Subarray

2007-04-25 Thread Arunachalam
Multiplication can be converted to addition by adding the log (ln). Then you need to find maximum sub array which sums to maximum. regards Arunachalam. On 4/25/07, Bootlegger <[EMAIL PROTECTED]> wrote: > > > We've all seen the maximum sum contiguous subarray problem, but heres > a new take on i

[algogeeks] Re: Maximum Product contiguous subarray

2007-04-25 Thread Vishal
1. If the array contains even number of negative numbers, then the answer is the whole array. 2. If it contains odd number of negative integers, split the array on every negative integer and calculate the product of two subarrays. Find the subarray (among all the subarrays from every split) with ma

[algogeeks] Re: Maximum Product contiguous subarray

2007-04-25 Thread Bootlegger
Aye its not the same, I suspect the answer will have something to do with verifying the number of negative numbers in the subarray, seen as a even number of negative numbers will produce a positive product and an odd number of negatives will produce a negative product. Bootlegger On 25 Apr, 13:

[algogeeks] Re: Maximum Product contiguous subarray

2007-04-25 Thread Nilesh Agrawal
> I think the problem is same as maximum sum..since product is max. if sum > is max. only thing we have to verify is that we should get even number of > negative numbers in our product.. Its not the same. Consider the sequence: 50, -25, -25 Max. Sum subarray : 50 Max. Product subarray: 50, -25,

[algogeeks] Re: Maximum Product contiguous subarray

2007-04-25 Thread chitta koushik
Hi, I think the problem is same as maximum sum..since product is max. if sum is max. only thing we have to verify is that we should get even number of negative numbers in our product.. On 4/25/07, Bootlegger <[EMAIL PROTECTED]> wrote: > > > We've all seen the maximum sum contiguous subarray probl