Re: Maximum Product Contiguous subarray
- From: Robby Goetschalckx <robby@xxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Apr 2007 15:35:21 +0200
Bootlegger wrote:
We've all seen the maximum sum contiguous subarray problem, but heres
a new take on it: maximum PRODUCT contiguous subarray:
Suppowe we have an array A[1 to n] of n integers (positive and
negative), Find the maximum product found in any contiguous subarray
and produce the pseudo-code for in.
I've had a crack and im struggling with this, apparently it can be
done in O(n) time.
Anyone any idea's?
My idea is that you should do your own homework. You should hurry up, too, as the deadline is approaching fast: (http://www.csc.liv.ac.uk/~pwong/teaching/comp108/assess/assess02.pdf)
Hint: if you're able to create an O(n) algorithm for the sum, you can use this for the product, too.
robby
.
- References:
- Maximum Product Contiguous subarray
- From: Bootlegger
- Maximum Product Contiguous subarray
- Prev by Date: Maximum Product Contiguous subarray
- Next by Date: Find the type
- Previous by thread: Maximum Product Contiguous subarray
- Next by thread: Find the type
- Index(es):