Implement prototype(sizes: list[int], amount: int) -> int and solve with the same signature. Unlimited copies of each positive integer size are available. Return the minimum number needed to total amount exactly, or -1 when impossible. amount=0 returns 0, including with sizes=[].

Examples: ([1, 3, 4], 6) returns 2; ([4, 6], 5) returns -1. Negative amounts or any nonpositive size raise ValueError.

Prototype: recursively explore choices without caching. Final: reuse smaller-amount results in O(amount*len(sizes)) time and O(amount) space. Preserve inputs, including on failure.

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.