Coding Challenge

Coin Change

Medium
dynamic-programming

Find the minimum number of coins to reach an amount.

Given coin denominations and a target amount, return the fewest number of coins needed to make that amount or -1 if impossible.

Examples

Input: coins = [1,2,5], amount = 11

Output: 3

Constraints

  • 0 <= amount

Preparing your coding workspace...