From charlesreid1

MVCS: Maximum value contiguous subsequence

Problem Description

Given a sequence of integers, Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle a_1, a_2, \dots, a_n} , determine the subsequence of integers with the maximum sum.

(Note, this problem is only interesting if there are negative numbers.)

Solution

This is a fairly straightforward dynamic programming problem that just requires evaluating the maximum sum for a sliding window, and store the results in a 1D array.

https://git.charlesreid1.com/cs/java/src/master/dynamic-programming/max-val-seq

Flags