0

To get the minimum difference between two groups seperated from a common sequence.

We have to take integer 'N' input from the user and then divide the sequence 1,2,3,4......N into two groups such that the difference of the sum of the numbers in a group should be minimum. For example, the input is 5 now we have the sequence {1,2,3,4,5} now divide this into two groups X={1,2,3}, Y={4,5} sum of X=6, sum of Y=9, absolute difference of two groups X-Y=3 but this is not minimum we can divide it into X={1,2,5}, Y={3,4} now sum of X=8 and sum of Y=7, the difference of two groups is 1 which is the minimum we can get.

14th Jan 2020, 1:49 PM
Giridhar Sharma
Giridhar Sharma - avatar
1 Answer
0
Please show us your attempt solving your task.
14th Jan 2020, 2:59 PM
HonFu
HonFu - avatar