#+ANKI_DECK: study_deck_02 * TODO 0322. Coin Change :medium: :PROPERTIES: :NEETCODE: [[file:../../roadmap.org::*0322. Coin Change][0322. Coin Change]] :END: You are given an integer array ~coins~ representing coins of different denominations and an integer ~amount~ representing a total amount of money. Return /the fewest number of coins that you need to make up that amount/. If that amount of money cannot be made up by any combination of the coins, return ~-1~. You may assume that you have an infinite number of each kind of coin. *Example 1:* #+begin_src Input: coins = [1,2,5], amount = 11 Output: 3 Explanation: 11 = 5 + 5 + 1 #+end_src *Example 2:* #+begin_src Input: coins = [2], amount = 3 Output: -1 #+end_src *Example 3:* #+begin_src Input: coins = [1], amount = 0 Output: 0 #+end_src *Constraints:* - ~1 <= coins.length <= 12~ - ~1 <= coins[i] <= 2^{31} - 1~ - ~0 <= amount <= 10^{4}~ ** TODO Approach Write your approach here. ** TODO Python #+begin_src python :lc-problem 322 :lc-lang python3 class Solution: def coinChange(self, coins: List[int], amount: int) -> int: #+end_src ** TODO C++ #+begin_src cpp :lc-problem 322 class Solution { public: int coinChange(vector& coins, int amount) { } }; #+end_src