This question was asked in a hiring round. As the round is over I am asking the question. Given N elements and a positive integer K divide the array into K segments/sub arrays such that maximum of sum of segments — minimum of sum of segments is minimized. Example given N=6 and K=3 a[]={7,2,3,1,2,3} .First segment is 7 ,Second is 2,3 and the Third is 1,2,3 .Max of {7,5,6}- Min of{7,5,6} = 2. While the N is pretty small. I would be thankful to any and all solutions possible.