How would I go about finding the maximum sum of an array with the following conditions:
- The summation must be consecutive.
- If there exist any 0's, it is consider a "break"
- The values in the sum of the array cannot be greater than the minimum value
EXAMPLE
1 0 1 0 0 = 1
2 0 2 1 1 = 3, why? [2 1 1] -> 1 + 1 + 1
3 1 3 2 2 = 6, why? [3 2 2] -> 2 + 2 + 2
4 0 0 3 0 = 4
I tried to think of a bottom up implementation, keeping track of the minimum value thus far while at the same time keeping track of the maximum sum, but I'm getting stuck...