# Stack of Boxes

Stack of Boxes

Source: Cracking the Code Interview 8.13

## Description

You have a stack of n boxes, with widths $w_i$, heights $h_i$, and depths $d_i$ . The boxes
cannot be rotated and can only be stacked on top of one another if each box in the stack is strictly
larger than the box above it in width, height, and depth. Implement a method to compute the
height of the tallest possible stack. The height of a stack is the sum of the heights of each box.

## 思路

• 若叠上去，则最高高度是在原高度加上j的高度加上以箱子j为底的那部分高度
• 若不叠上去，则最高高度是原高度加上以箱子i为底的那部分高度