The TransCompilator

Solved LeetCode program · 970 of 1,000

#1340 · Jump Game V

Hard Array chunk-20.md

Original English source

Keep a shared heights holding 6, 4, 14, 6, 8, 13, 9, 7, 10, 6, and 12. Keep a shared order as an empty list of whole numbers. Keep a shared lengths as an empty list of whole numbers. Keep a shared span of 0. Keep a shared best of 0. Keep a shared lowest of 0. Keep a shared clear of 0. Keep a shared record of 0. Set span to 2. Set record to 1.
For every slot from 0 to 10.
Place slot into order. Place 1 into lengths.

To choose from start (a whole number). Set best to start. Set lowest to item (item start of order) of heights.
For every which from start to the last position of order.
The spot is item which of order. If item spot of heights is less than lowest, set best to which, set lowest to item spot of heights.

To inspect from spot (a whole number) with low (a whole number) and high (a whole number). Set clear to 1.
For every probe from low plus 1 to high minus 1.
If item probe of heights is at least item spot of heights, set clear to 0.

For every place from 0 to the last position of order.
Choose from place. swap item place of order and item best of order.

For every rank from 0 to the last position of order.
The spot is item rank of order.
For every other from 0 to the last position of heights.
The gap is the absolute value of (other minus spot).
If item other of heights is less than item spot of heights and gap is at most span.
The low is the smaller of spot and other. The high is the larger of spot and other. Set clear to 1. If high is more than low plus 1, inspect from spot with low and high. If clear is 1 and item other of lengths plus 1 is more than item spot of lengths, set item spot of lengths to item other of lengths plus 1. If item spot of lengths is more than record, set record to item spot of lengths.

Show record.

Open in Playground Browse all 1,000 problems

Expected stdout

4