HARDasked at 1 company

Maximum Height by Stacking Cuboids

A hard-tier problem at 60% community acceptance, tagged with Array, Dynamic Programming, Sorting. Reported in interviews at Samsung and 0 others.

Founder's read

Maximum Height by Stacking Cuboids is a DP problem that looks like Tetris but plays like a sorting puzzle. Samsung reports asking it. The twist: you can rotate each cuboid before stacking, and the rules for valid stacking are unintuitive enough that candidates often misread them on the live OA. The acceptance rate sits around 60%, which means half the people who attempt it walk away with nothing. If this problem hits your assessment and you blank on the rotation logic or the DP state, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
1
Difficulty
HARD
Acceptance
60%

Companies that ask "Maximum Height by Stacking Cuboids"

If this hits your live OA

Maximum Height by Stacking Cuboids is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.

Get StealthCoder
What this means

The core trick is understanding that rotation is mandatory preprocessing, not optional optimization. You must consider all rotations of each cuboid and normalize them so that two dimensions are always the smallest two. Then sort the cuboids by a composite key (not just one dimension), and run a 1D DP where each state represents the maximum height achievable with a given base footprint. The pitfall: candidates lock into simple sorting by one dimension and miss that a cuboid can be stacked only if both its base dimensions are strictly smaller than the current top. This isn't a greedy problem. You'll iterate through all previous states and check validity before updating. If you haven't drilled this specific DP pattern before, StealthCoder is the hedge that delivers the correct state transition in seconds during your live assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Maximum Height by Stacking Cuboids recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Height by Stacking Cuboids interview FAQ

Is this really a hard problem or does it just sound hard?+

It's hard. The 60% acceptance rate reflects that most people get the rotation logic right but lose points on the DP transition or sorting key. The problem description itself is dense. It's not a 'practice a few variants and you own it' kind of hard; it's a 'get the pattern wrong once and you're done' hard.

Does Samsung still ask this, or is it outdated?+

Samsung is the company flagged in reports for this problem. It may appear elsewhere, but Samsung is the primary signal. No way to know if it's still actively used in their loop right now, but enough candidates have reported it that it's worth treating as live.

What's the trick I'm missing when I sort?+

You can't sort by just one dimension. A valid stack requires both dimensions of the new cuboid to be strictly less than the current top. Sort by the first dimension ascending, then by the second dimension descending. This order ensures you process cuboids in an order where DP decisions are consistent.

How does this relate to the other DP stacking problems I've seen?+

It's a step up from classic 1D stacking DP because you have two constraints (both base dimensions must be smaller), not one. Array and Sorting are prerequisites; they set up the DP. You'll need to be comfortable with 1D DP transitions before this lands right.

Can I pass this with a brute force rotation + recursive approach?+

Not cleanly. Brute force on rotations and recursion will time out or miss optimal substructure. You need the DP table. The acceptance rate and hard difficulty suggest the problem is designed to reward the right DP pattern and punish guessing.

Want the actual problem statement? View "Maximum Height by Stacking Cuboids" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.