I had an interesting interview problem today. Let's assume that we have n boxes, containing many numbers. For instance, let's say $n=4$, and four boxes contain the following numbers:
first box - (3, 2, 5) sum(first box) = 10
second box - (1, 7, 4, 8) sum(second box) = 20
third box - (10, 5, 9) sum(third box) = 24
fourth box - (11) sum(fourth box) = 11
Let's assume that we're given $'k'$, the number of times we could move a number from one box to another. What would be the best way to use that limited number of moves, so that
$max( sum(box_i) )$
which in the above case would be
max( sum(first box), sum(second box), sum(third box), sum(fourth box) )
is minimum?
For instance, in the above example, if $k=1,$ then the best move would be to move 5 or 9 to first or fourth box.
I was just using the greedy algorithm approach, but I was wondering if there are some well-known algorithms for this type of problem or similar type of problems.
This is not a full answer, but it's too long for a comment. The greedy method will not be good here. Imagine two boxes, the first containing $(1,1,1,20)$ and the second $(3,2)$. Now the greedy method will take the $20$ out of the first into the second and then back, but in fact, after $3$ moves, you can arrive at the optimal solution of $(20), (1,1,1,3,2)$.
I don't see how any version of the greedy method would be able to find this solution...