Coin change dynamic programming: Given positive coin denominations and a non-negative amount, return the minimum number of coins needed to make the amount, or -1 when it is impossible. Coins may be reused.
Input: A JSON object { "coins": number[], "amount": number }.
Output: A JSON integer.
Constraints:
- 0 <= amount <= 100000
- Every coin denomination is positive
- Coin order does not affect the answer
Read one JSON value from stdin and print exactly one JSON-serialized answer to stdout with no extra text.
Difficulty: HARD. Variant: 9. Balance correctness, maintainability, and clear review-ready code.
Practice context
This coding (algo) exercise trains prompt interpretation, explicit assumptions, a concrete response, and a concise explanation of the decisions made. It is marked hard difficulty.
The signed-in workspace provides the tools required by the round, such as recordin