The TransCompilator

Solved LeetCode program · 448 of 1,000

#0632 · Smallest Range Covering Elements from K Lists

Hard Array chunk-09.md

Original English source

Keep a shared values holding 4, 10, 15, 24, 26, 0, 9, 12, 20, 5, 18, 22, and 30. Keep a shared begins holding 0, 5, and 9. Keep a shared sizes holding 5, 4, and 4. Keep a shared target of 0. Keep a shared smallest of 0. Keep a shared foundone of 0. Keep a shared complete of 0. Keep a shared highest of 0. Keep a shared bestlow of 0. Keep a shared besthigh of 0. Keep a shared bestwidth of 1000000000.
To find from group (a whole number) with spot (a whole number). The base is item group of begins. The size is item group of sizes. If spot is at least size, set foundone to 0, return. The value is item (base plus spot) of values. If value is at least target, set smallest to value, set foundone to 1, return. Find from group with spot plus 1.

To test from spot (a whole number). Set target to item spot of values. Set highest to -1000000000. Set complete to 1.
For every group from 0 to 2.
Set foundone to 0. Find from group with 0. If foundone is 0, set complete to 0. If smallest is more than highest, set highest to smallest. If group is 2 and complete is 1 and highest minus target is less than bestwidth, set bestwidth to highest minus target, set bestlow to target, set besthigh to highest.

For every spot from 0 to 12.
Test from spot.

The report is empty text. Place format whole number bestlow as text into report. Place "," into report. Place format whole number besthigh as text into report. Show report.

Open in Playground Browse all 1,000 problems

Expected stdout

20,24