Find the Substring With Maximum Cost
Kadane-style DP: the best substring ending at each position is max(0, previous + value), and the answer is the best of these.
Kadane-style DP: the best substring ending at each position is max(0, previous + value), and the answer is the best of these.