Subj : Re: question about finding sum of subset of contiguos elements of an array . To : comp.programming From : Willem Date : Thu Oct 06 2005 09:55 pm Alf wrote: )> I don't understand the problem. Is it, find the contigous sequence of )> elements with highest sum? Then just scan the array noting the end of a )> sequence when a negative number is encountered, and noting the start of a )> sequence when after a negative number, a non-negative number is encountered. )> If there are no non-empty such sequences, pick the first negative number that )> is of lowest absolute value. But that can't be the problem, can it? ) ) Ah, my bad. If a positive number sequence sums to higher than the absolute ) value sum of the preceding negative number sequence, or the succeeding one, ) then that presents opportunities for coalescing the sequences. OK, there's a ) problem. See ? That's why this is such a nice CS problem. Provided the students try to work it out for themselves, instead of tunning to a newsgroup for help. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT .