103 - Stacking Boxes


Difficulty : medium

Solution Description :

Graph DFS with longest path print (DAG)

Sort all boxes by their smallest dimension (ties broken by further dimensions if necessary) .
Create a directed graph where nodes are boxes, and i points to j if i can contain j. Then do DFS for each box i to find the maximum depth. 
Print maximum depth and path for the maximum depth.