Question bank › Stack
Dsa Stack Medium

Tower of Boxes

You have a stack of boxes, each with a width, height, and depth. You can only stack a box on top of another box if its dimensions are all strictly less than those of the box below it. Given the dimensions of a series of boxes, your task is to determine the maximum height you can achieve by stacking the boxes. Input consists of an integer n followed by n lines of box dimensions (width, height, depth). Output the maximum height of the stacked boxes. Example input: 3 1 2 3 2 3 4 3 4 5 Output: 6

Key concepts

stackgreedysorting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.