Q1: Given array, delete the maximum contiguous subarray of size k from the original array and return the sum
Approach: Find maximum contiguous subarray sum of size k, subract from the sum of original array
Q2: Given array, return the index of the least absolute difference of the averages from two parts of the array
Testcase 1:
5
1 3 2 4 5
Output:
1
Explanation:
Index 1: [1], [3,2,4,5]
Averages are 1 and 3 respectively (floor is mentioned in the question)
abs(1 - 3) = 2
Index 2: [1,3], [2,4,5]
Averages are 2, 3
abs(2 - 3) = 1
Index 3: [1,3,2], [4,5]
Averages are 2, 4
abs(2 - 4) = 2
Index 4: [1,3,2,4], [5]
Averages are 2, 5
abs(2 - 5) = 3
Index 2 has least difference, so return 2