23andme二面

/* 
"""
A valid tail-sequence of an array meets the following criteria:
- Contains multiple consecutive elements of the array
- Contains the first OR last element of the array
- Does not contain the first AND last element of the array

As an example, for array, [1, 2, 3, 4], the valid tail-sequences are:
[1, 2], [1, 2, 3], [2, 3, 4], [3, 4]

Implement a function, aggregateMaxTailSequenceSums(), which:
- Accepts argument:
  - An array of integers
- Outputs:
  - An integer which is the maximum possible sum of all elements using one or
    more tail-sequences found in the array
  - If no tail-sequence exists in the array, the function should return null

Examples:
1. aggregateMaxTailSequenceSums([-2, 3, -1, 2, 0], 2) => 10
(using tail-sequences [-2, 3] => 1, [-2, 3, -1, 2] => 2, [3, -1, 2, 0] => 4,
[-1, 2, 0] => 1, [2, 0] => 2)

[3, -1, 2, 0] => 4

[-2, 3, -1, 2] => 2
[2, 0] => 2

6

2. aggregateMaxTailSequenceSums([1, -6, 2, -7, 4, -4]) => 0
(using tail-sequence [4, -4])
"""

3. aggregateMaxTailSequenceSums([-1, -2, -4, 1]) => -3
(using either tail-sequence [-1, -2] or [-4, 1])

*/

follow up: only maximum of tail sequence could be used.