Arrange n items in k nonempty groups such that the difference between the minimum element and the maximum element of each group is minimized
<p>Given <em>N</em> items with values <code>x[1], ..., x[n]</code> and an integer <em>K</em> find a linear time algorithm to arrange these <em>N</em> items in <em>K</em> non empty groups such that in each group the range (difference between minimum and maximum element values/keys in each group) is minimized and therefore the sum of the ranges is minimum.</p>

<p>For example given <code>N=4</code>, <code>K=2</code> and the elements <code>1 1 4 3</code> the minimum range is <code>1</code> for groups <code>(1,1)</code> and <code>(4,3)</code>.</p>