Prove that difference between maximum tension and minimum tension equal to 6mg
Answers
Given an array of integer values, we need to find the minimum difference between maximum and minimum of all possible K-length subsets.
Examples :
Input : arr[] = [3, 5, 100, 101, 102]
K = 3
Output : 2
Explanation : Possible subsets of K-length with
their differences are,
[3 5 100] max min diff is (100 - 3) = 97
[3 5 101] max min diff is (101 - 3) = 98
[3 5 102] max min diff is (102 - 3) = 99
[3 100 101] max min diff is (101 - 3) = 98
[3 100 102] max min diff is (102 - 3) = 99
[3 101 102] max min diff is (102 - 3) = 98
[5 100 101] max min diff is (101 - 5) = 96
[5 100 102] max min diff is (102 - 5) = 97
[5 101 102] max min diff is (102 - 5) = 97
[100 101 102] max min diff is (102 - 100) = 2
As the minimum difference is 2, it should
be the answer for given array.
Input : arr[] = {5, 1, 10, 6}
k = 2
Output : 1
We get the above result considering subset
{5, 6}