* Maximum Length Acceptable Segment Sum
So, we must find all segments that sum above the threshhold k, but return only the
longest such segment (not the one with the largest sum).
Please see my solution for "Maximum Segment Sum" (MSS).
We start the compacting and accumulating steps as provided.
However, during accumulation, if our accumulated sum is greater than or equal to
k, then we switch to comparing accumulation sums to k, not the sum of the accumulator.
Now, after all the sequence is compacted, choose all summations that meet the threshhold
(e.g., store them in a list, or delete unacceptable summations).
Previously, we stored the leftmost index of each of the summations. From these indices
we can derive the segment length of these summations in the manner previously described.
Remember to do this before altering the results from MSS.
From our list of acceptable answers, if there are any, choose the one with the longest
segment.
Return this answer or a useful error if there are no acceptable solutions.
Complexity is dominated by MSS. We can use any suitable search algorithm to find
the acceptable sums and the longest segment.
=========================
= Update Log
=========================
20060626 -- 8:30 EST -- Correction. My MSS algorithm will find the largest sum,
but the MLASS cares only about length after the threshhold is
reached by any MSS-style accumulator.
20060626 -- 6pm EST -- Original posting.