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: EASY. Variant: 19. Expect follow-up questions about complexity, edge cases, and alternative approaches.
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 easy difficulty.
The signed-in workspace provides the tools required by the roun