Nested Gift Parcels
Preview mode. Log in to edit, run, submit, and save progress.
Hard
Nested Gift Parcels
You are packing display parcels for a launch event. Each parcel has a width and height. One parcel can be placed inside another only if both its width and height are strictly smaller. Return the maximum number of parcels that can be nested into one chain.
Examples
Example 1
Input:
parcels = [[5,4],[6,4],[6,7],[2,3]]
Output:
3
Explanation: [2,3] can fit into [5,4], which can fit into [6,7].
Approach hint
Sort first.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp