Log in
← All problems

Fewest coins

hardProblem solving40 XP

You have coins of the values in coins, as many of each as you like. Return the fewest coins that add up to exactly amount, or -1 if it can't be done.

Examples

Examples use JSON: true/false/null are True/False/None in Python.

Run examples checks the examples above. Submit also runs 4 hidden tests.