216. Coin Change

MediumDynamic Programming

Given an integer array coins and an integer amount, return the fewest number of coins needed to make up that amount. Return -1 if impossible.

Examples

Input: [1,2,5] 11

Output: 3

Explanation: Public test case for Coin Change

Constraints

  • 1 <= coins.length <= 12
  • 1 <= coins[i] <= 2^31 - 1
  • 0 <= amount <= 10^4
Loading...

Run checks all cases above. Submit evaluates all test cases.