Russian Envelope Chain Problem

Russian Envelope Chain Problem — ExecCode Hard DSA Practice

Solve the Russian Envelope Chain problem on ExecCode. Free online hard DSA practice in DP. Write and run code in Java, C++, Python — no signup required to run.

Problem description

You may nest envelope A inside B only if both width and height of A are strictly smaller. Maximize the number of nested envelopes. Return the maximum chain length. You are given: envelopes — list of [w, h] Return integer >= 1 if there is at least one envelope. A single envelope is a chain of 1.

Examples

Input {'envelopes': [[5, 4], [6, 4], [6, 7], [2, 3]]}; Output 3. Input {'envelopes': [[1, 1], [1, 1], [1, 1]]}; Output 1. Input {'envelopes': [[4, 5], [4, 6], [6, 7], [2, 3], [1, 1]]}; Output 4

Constraints

Equal width or equal height cannot nest Rotation is not allowed

Practice Russian Envelope Chain free on ExecCode. Browse DSA problems, topic map, and placement guides.