Given a slice a. There are 2 sub slices. One’s length is k, the other’s is p. These 2 sub slices are not overlaid. Find the max sum of the 2 sub slices.
Return -1 if can’t find one.
Example 1:
1 2
Input: [1,3,4,7,5,8,2,9], 3, 2 Output: 35
Example 2:
1 2
Input: [1,3,4,7,5,8], 100, 2 Output: -1
Thought
Move slice K through A, at the left and right side of K place the slice P. To improve the efficiency, store sums of K and P in hash tables.