Conviva interview question

Box stacking problem. The classic dynamic programming problem.