Given N denominations,how can a given amount of money V be made with the least number of coins? The most intuitive solution is greedy algorithm: sort the denominations, try the largest denominations lower than the value every time, and decrease the value with the denominations picked in every iteration. Repeat this process until the value reduces to 0. This greedy strategy works for the US (and most other) coin systems, However, it is not a general solution to all denomincations. For example, if the coin denominations were 1, 3 and 4, then to make 6, the greedy algorithm would choose three coins (4,1,1) whereas the optimal solution is two coins (3,3).
Actually the change-making problem is a knapsack type problem, which can be solved efficiently by Dynamic Programming.
- See more at: http://bo-yang.github.io/2014/06/20/coin-change/#sthash.m2CdaXkq.dpuf