Question: You will be given two integers N and K , in addition to an array Arr of size N . You can calculate the function

You will be given two integers N and K, in addition to an array Arr of size N.
You can calculate the function F(Arr) as follows:
|Arr i - Arr i+k| from i =0 to n-k
You are allowed to rearrange the elements of Arr any way you want.
Find the minimum possible value of F(Arr). Since the answer can be very large return i modulo 10^9+7.
Notes:
It is given that Arr follows 1 basedindexing.
Input Format
The first line contains an integer, N, denoting the number of elements in Arr.
The next line contains an integer, k, denoting the value of k to use in calcuang F(Arr)
Each line i of the N subsequent lines (where 1= i = N) contains an integer descring A
Constraints
1= N=10^5
1=K=minN-1,4*10^3
-10^9Arr[i=10^9You will be given two integers N and K, in addition to an array Arr of size N
You can calculate the function Arr
 You will be given two integers N and K, in addition

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!