This challenge is a harder version of a previous challenge (which you should solve first), solving the same problem, but with much harder tests which require the solution to be pretty efficient (see Notes below).
The problem in question is the max sum sublist pair problem which, given a list of numbers, tries to find the pair of sublists with the maximum possible combined sum.
For example:
[1, 6, -1, -5, -2, 5, -1, 4, -7, 1, 2, 3]
The max sum sublist pair is [1, 6], [5, -1, 4] which has combined sum 1 + 6 + 5 - 1 + 4 = 15.
Notably, in this challenge, we allow for empty sublists [], whose sum is 0. Thus, for the list:
[-1, -2, -3, 5, 4, 3, 4, 5, -9, -10]
The max sum sublist pair is [5, 4, 3, 4, 5], [] with total sum 5 + 4 + 3 + 4 + 5 = 21.
Write an efficient function which, given a list of numbers, returns the total sum of the max sum sublist pair.
[1, 6, -1, -5, -2, 5, -1, 4, -7, 1, 2, 3] ➞ 15
# Max sum sublist pair is [1, 6], [5, -1, 4]
[-1, -2, -3, 5, 4, 3, 4, 5, -9, -10] ➞ 21
# Max sum sublist pair is [5, 4, 3, 4, 5], []
[-4, 2, -3, -2, 2, -3, 5, -2] ➞ 7
# Max sum sublist pair is [2], [5]
[0, -1, 5, -6, 5, -3, 0, -4, 5, 2, -5, 1] ➞ 12
# Max sum sublist pair is [5], [5, 2]
[-5, 3, -4, 6, 0, 0, -4, -2, -2, 7, -5, 7, -5, 5] ➞ 15
# Max sum sublist pair is [6], [7, -5, 7]