Can anyone solve it please!!!
Anonymous User
276

We have given an array of positive integers in sorted order and a number N. We have to select N numbers from the array such that the sum of absolute difference is minimum.
Example:
arr=[1 ,2 ,3 ,6 ,7 ,9,11, 22 ,44,50] and N=5
Output: 9
Explaination:
if we select- 2 7 11 22 50 then sum of absolute difference=11
if we select-2 7 22 44 50 then sum of absolute difference=9
so, ans=min(9,11)=9

Comments (2)