Trains the technique from
LeetCode 354Russian Doll EnvelopesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A museum stores glass display cases of many sizes. Case i is given as cases[i] = [width, depth].
One case slides inside another only when it is strictly narrower and strictly shallower than that case; matching either measurement is enough to jam it. Cases may be nested one inside the next as many levels deep as the sizes allow, and a case is never turned on its side, so width is always compared against width and depth against depth.
Return the greatest number of cases that can sit in a single nest, counting the outermost case.
Example 1
The case measuring 3 by 4 slides into the one measuring 4 by 8, which slides into the one measuring 8 by 9, so three cases share a nest.
Example 2
Two cases of identical size jam against each other, so a nest holds only one of them.
Example 3
The narrow case is deeper and the wide case is shallower, so neither one fits inside the other.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def deepest_case_nest(cases: list[list[int]]) -> int:public int deepestCaseNest(int[][] cases)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.