The O(N) solution which I can think of.
We need to divide the array in subarray's with division point being 0.
Now, in those sub arrays, there are two cases:
First- even number of -ve numbers, then max product of that subarray will be
product of all elements.
If it contains odd number, then take the product of sub array and divide it
with min( MOD(product from start to first- ve number),( last -ve number till
end))


On Wed, Jul 13, 2011 at 10:03 AM, shilpa gupta <[email protected]>wrote:

> array contain negative numbers also including natural numbers correct it...
>
>
> On Wed, Jul 13, 2011 at 9:43 AM, shilpa gupta <[email protected]>wrote:
>
>> given an array of natural numbers (+ve, 0, -ve) find the maximum
>> product of continuous elements.efficient( O(nlogn) or better)solution
>> is needed.
>> thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> shilpa gupta
> b tech 2nd year
> computer science and engineering
> mnnit allahabad
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to