# nested boxes algorithm

I am given a set of 3D boxes {$$B_1$$, $$B_2$$...$$B_n$$} and each box have length, width and height. But these values are interchangeable since I can rotate the box. I need to find out the maximum sequence of nested boxes.

I have tried this problem using sort. But I still get stuck. I used built in sort function to sort all boxes by length in ascending order. I read the reference about this question and learned that people used radix sort. I have know idea how radix sort is applied here because all sorts I am familiar is comparison sort.

This surely is a bit overkill and is probably also not the most efficient solution ($$O(n^2)$$ for building the graph).
• Good algorithm. But in this question the boxes can be rotated. I think comparing boxes is more complicated than $O(n^2)$ – hck007 Oct 14 at 15:32