โœ๏ธ

Coin Change

Medium๐Ÿท๏ธ Dynamic programming๐Ÿ“‚ Greedy & Dynamic Programming
๐Ÿงฉ The problem

Return the fewest coins needed to make amount, or -1 if impossible. You have unlimited coins of each value.

Examples

  • [1, 2, 5], 11 โ†’ 3 (5 + 5 + 1)

๐ŸŽฏ Aim for: O(amount ร— coins)

โœ๏ธ Write your solution

Pick a language, press Run to try it, then Run tests to check it against every test case โ€” just like a coding interview.

โ† All practice problems