Maximum sum of absolute difference b/w adjacent elements after removing k elements from the array.

Revision en1, by deepak_097, 2019-05-14 22:03:58

Suppose we have an array which consist of n elements: a1, a2, a3, ..... , an and we have given the value of k which is the count of removed elements from the array. So after removing k elements from the array what is the maximum value of absolute difference of the adjacent elements of the array. Suppose,

n=5 k=3

1 2 5 2 1

then we remove 1,2,2 then the remaining elements of the array will be 5 1 so, ans=abs(5-1)=4 (maximum value which we can get).

Tags array, #logic

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English deepak_097 2019-05-14 22:03:58 560 Initial revision (published)