Implement prototype(loads: list[int]) and solve(loads: list[int]) in exercise.py. Both return a tuple (total: int, first_maximum_index: int | None). Inputs contain nonnegative integers. Ties choose the smallest original index; [] returns (0, None).

Example: [8, 2, 8] returns (18, 0). A single zero returns (0, 0).

For the prototype, make a direct scan. For the final version, keep the running total and first maximum index in one O(n) scan with O(1) auxiliary space. Do not sort or mutate the input. There are no additional validation requirements beyond these documented inputs.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.