Maximum Sum Of Two Non-overlapping Subarrays

1. You are given an array(arr) of positive numbers and two numbers X and Y.
2. You have to find the maximum sum of elements in two non-overlapping subarrays.
3. One subarray must of length X and the other must be of length Y.
Input Format
A number N
arr1
arr2.. N numbers
Two numbers X and Y
Output Format
A number representing maximum sum of elements in two non-overlapping subarrays. 
Question Video
Constraints
1 <= N <= 1000
0 <= arr[i] <= 1000
X >= 1, Y >= 1
X + Y <= N
Sample Input
9
0 6 5 2 2 5 1 9 4
1
2
Sample Output
20


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name