Given an array of n integers where each value represents number of chocolates in a packet. Each packet can have variable number of chocolates. There are m students, the task is to distribute chocolate packets such that :
1) Each student gets one packet.
2) The difference between the number of chocolates in packet with maximum chocolates and packet with minimum chocolates given to the students is minimum.
Input : arr[] = {7, 3, 2, 4, 9, 12, 56}
m = 3
Output: Minimum Difference is 2
We have seven packets of chocolates and we need to pick three packets for 3 students
If we pick 2, 3 and 4, we get the minimum difference between maximum and minimum packet
sizes.
Answer
Answer
No comments:
Post a Comment