Here is a better explanation:

Define a sublist of a list l to be a list containing 0 or more contiguous elements

of l. For instance, the list (1, 2, 3) has seven sublists: the empty sublist; three sublists of length 1: (1), (2), and (3);

two sublists of length 2: (1, 2) and (2, 3);

one sublist of length 3: (1, 2, 3).

The problem we want to solve is this: given a list of integers, find the maximum

sum of the elements of a sublist. For example, the following lists have sublists

with maximum sum as shown.

Code:

list sublist with max sum max sum
(-2, 4, -3, 5, 3, -5, 1) (4, -3, 5, 3) 9
(2, 4, 5) (2, 4, 5) 11
(-1, -2, 3) (3) 3
(-1, -2, -3) () 0

## Bookmarks