From: Matt Greer Date: 2007-07-14T02:57:10+09:00 Subject: Re: [QUIZ] Maximum Sub-Array (#131) ------=_Part_41614_12759555.1184349433841 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/13/07, anansi wrote: > > could someone explain this please? I really don't understand this quiz? > > Given an array of integers, find the sub-array with maximum sum. For > > example: > > > > array: [-1, 2, 5, -1, 3, -2, 1] > > maximum sub-array: [2, 5, -1, 3] > > I know what an array is :) I know what integers are :) I know what a sum > is :) > > but why is [2, 5, -1, 3] sum= 9 the sub-array with the maximum sum? > wouldn't be [2,5,3,1] sum=11 the right solution? A sub-array is a contiguous list within the overall array. For [a,b,c], the sub-arrays are [a], [b], [c], [a,b], [b,c] and of course [a,b,c], but [a,c] is NOT a sub-array because the elements are not contiguous within the overall array. I'm looking forward to tackling this quiz this evening, what a rocking Friday night it will be! :) Matt ------=_Part_41614_12759555.1184349433841--