Learn

Technical Interview Problems in Python: Lists

Max list sub-sum: Naive

Our next problem calculates sums within a list.

Given a list of integers, return the **maximum sum possible from a contiguous sub-list**. A sub-list is an uninterrupted portion of the list (up to and including the entire list).

nums = [1, -7, 2, 15, -11, 2] maximum_sub_sum(nums) # 17 # The sum of sub-list nums[2:4]

**Clarifying Questions:**

- Are there constraints on time or space efficiency?
- No! Any solution will do.

- Are all the numbers positive?
- No! Negative numbers can be in the input.

- How big or small can the sub-list be?
- From a single element to the entire list.

### Instructions

**1.**

Write a function `max_sub_sum()`

which has a single parameter: `my_list`

.

`max_sub_sum()`

should return the maximum sum of contiguous values in `my_list`

.