You have N boxes of various sizes. You would like to stack some of them upon each other to create a tower that's as tall as possible.
When building the tower, you are allowed to reorder and rotate the boxes. However, the tower must obey the following rules:
- The tower must be constructed by repeatedly taking an unused box and placing it on top of the current tower.
- Each box must have sides parallel to the sides of the bottommost box.
- If a box A is placed on box B, then the entire bottom side of A must be placed on the top side of B. In other words, no part of the bottom side of A may overhang the top side of B.
You are given the dimensions of the boxes as three int[]s x, y, and z.
The i-th elements in x, y, and z specify the dimensions of the i-th box.
Return an int giving the height of the tallest tower that can be constructed using the above rules.
|