The TransCompilator

Solved LeetCode program · 262 of 1,000

#0354 · Russian Doll Envelopes

Hard Array chunk-06.md

Original English source

Keep a shared widths holding 5, 6, 6, and 7. Keep a shared heights holding 4, 4, 7, and 8. Keep a shared memo as an empty list of whole numbers.
For every spot from 0 to 3.
Place 0 into memo.

To chain from index (a whole number). If index is 0, set item 0 of memo to 1, return. If item index of memo is more than 0, return. The best is 1.
For every prior from 0 to index minus 1.
The narrow is item prior of widths. The short is item prior of heights.
If narrow is less than item index of widths and short is less than item index of heights.
Chain from prior. The candidate is item prior of memo plus 1. If candidate is more than best, set best to candidate. Set item index of memo to best.

The answer is 1.
For every spot from 0 to 3.
Chain from spot. If item spot of memo is more than answer, set answer to item spot of memo.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

3