All pastes #356693 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-02-15 06:31 UTC
rendered paste body
Augment the algorithm given above so that in addition to providing the maximum (contigu-ous) subsequence sum (max ), it also provides the indices for the starting and ending terms inthe subsequence associated with max. This means that your modification should determinethe correct values for start (the index for the first term in the subsequence that produced themaximum sum) and end (the index for the last term in the subsequence that produced themaximum sum). So, for instance, for the sequence -2, 11, -4, 13, -5, 2, the algorithm correctlyfinds the maximum subsequence sum max = 20, start = 1, stop = 3