Amazon OA
Anonymous User
2233

Given an array consisting of N integer and two number k,d.
Task1-From the given array we can choose k consecutive elements one after in array and after that leave an array element.Then we calculate maximum sum of all such consecutive element containing subarray.
Task2-From the given array we can choose k+d consecutive elements one after in array and after that leave an array element.Then we calculate maximum sum of all such consecutive element containing subarray.
Find the difference between task1 and task 2 ans.
ex 1->arr=[1,2,3,4,8,9,10]
k=2,d=1;
Task1 elements {3,4}+{9,10}=7+19=26
Task2 elements {1,2,3}+{8,9,10}=6+27=33;
output=33-26=7

Comments (5)