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]
- 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.
Write a function
max_sub_sum() which has a single parameter:
max_sub_sum() should return the maximum sum of contiguous values in