The TransCompilator

Solved LeetCode program · 980 of 1,000

#1354 · Construct Target Array With Multiple Sums

Hard Array chunk-20.md

Original English source

Keep a shared target holding 9, 3, and 5. Keep a shared size of 0. Keep a shared total of 0. Keep a shared top of 0. Keep a shared rest of 0. Keep a shared next of 0. Keep a shared possible of 0. Set size to 3. Set total to 17. Set possible to 1.

To highest. Set top to 0.
For every spot from 0 to the last position of target.
The place is top. If item spot of target is more than item place of target, set top to spot.

Repeat while total is more than size.
Highest. The place is top. Set rest to total minus item place of target. If item place of target is at most rest, set possible to 0, stop. Set next to item place of target minus rest. Set item place of target to next. Set total to rest plus next.

If possible is 0, show false, otherwise show true.

Open in Playground Browse all 1,000 problems

Expected stdout

true