Math, asked by Avni8494, 1 year ago

Difference of largest and smallest numbers in subset

Answers

Answered by shyam999
0

Input : a[] = [5, 4, 2, 1, 3],

k = 3, d = 5

Output : 10

Explanation:

{1,2,3}, {1,2,4}, {1,2,5}, {1,3,4}, {1,3,5},

{1,4,5}, {2,3,4}, {2,3,5}, {2,4,5}, {3,4,5}.

We can see each subset has atmost

difference d=5 between the minimum

and maximum element of each subset.

No of such subsets = 10

Input : a[] = [1, 2, 3, 4, 5, 6],

k = 3, d = 5

Output : 20

Similar questions