103 - Stacking Boxes

The longest path problem in general is NP-hard, but since the graph \(G\) constructed from the ‘nests-in’ relation is a directed acyclic graph, we may solve it by solving the shortest path problem of \(-G\).

Other than that, this problem is quite straightforward to solve.

Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.