Trains the technique from
LeetCode 1043Partition Array for Maximum SumThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
An orchard is planted as one long line of rows. You are given yields, where yields[i] is the crop weight recorded for row i, and an integer span.
At grading time the manager cuts the line into consecutive blocks. Every row belongs to exactly one block, and a block holds at least one row and at most span rows. Each row is then written into the season report with the heaviest weight found anywhere in its own block, and the season figure is the sum of the written weights over all rows.
Return the largest season figure that some cut into blocks produces.
Example 1
Cutting into the blocks [4], [1, 1, 12] and [2, 6, 3] writes 4, then 12 three times, then 6 three times, giving 4 + 36 + 18 = 58.
Example 2
Cutting into the blocks [1] and [1, 9] writes 1, then 9 twice, giving 1 + 18 = 19.
Example 3
Cutting into the blocks [6, 2], [5, 1], [8, 3] and [4] writes 12 + 10 + 16 + 4 = 42.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_graded_total(yields: list[int], span: int) -> int:public int maxGradedTotal(int[] yields, int span)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.