The TransCompilator

Solved LeetCode program · 806 of 1,000

#1043 · Partition Array for Maximum Sum

Medium Array chunk-17.md

Original English source

The numbers is a list of 1, 15, 7, 9, 2, 5, and 10. The span is 3. The count is 7. The best is a list of 8 zeros.
For every finish from 1 to count.
The largest is 0.
For every width from 1 to span.
If width is at most finish.
The start is finish minus width. The here is item start of numbers. If here is more than largest, set largest to here. The candidate is item start of best plus width times largest. If candidate is more than item finish of best, set item finish of best to candidate.

Show item count of best.

Open in Playground Browse all 1,000 problems

Expected stdout

84