Question 2
Given an array A
of size n
. Choose two non-intersecting subarrays (can be empty) such that total sum of elements of subarrays is maximum. Non-intersecting subarrays means no element is common between them.
Contraints
1 <= N <= 10^3
-10^9 <= Ai <= 10^9
Examples
1) A = [-4,-5,-2] , sub1 = [], sub2 = [] , answer = sub1+sub2 = 0
2) A = [5 -2 3 -6 5], sub1 = [5,-2,3] , sub2 = [5], answer = 11
3) A = [-9,5,-9,-8,9,7,-10,10,9], sub1 = [9,7], sub2 = [10,9], answer = 35
4) A = [1,2,3,4,5,6,7,8], sub1 = [1,2,3,4,5,6,7,8], sub2 = [], answer = 36