A circular array is given, we can divide this array into K groups of contiguous elements such that difference of maximum sum and minimum sum is minimum.
For Example:
Array is 6, 13, 10, 2 & K = 2
i -
6, 25 where 25 = 13 + 10 + 2
So diff is = 19, because there is only two element, so its very obivious which one is max sum or which one is min sum
//Suppose K = 3 then we can say 6 , 23, 2 in this case we will find difference between 23 & 2 i.e. 21.
ii -
19, 12 where 19 is 6 + 13 & 12 = 10 + 2
...
...
Answer after analysing on each combination is
16, 15
where 16 = 6 + 10 & 15 = 13 + 2 and difference is 1.
So through a program we need to find 16, 15 like set.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.