菜鸟说动态规划
从我学习至今,我有三大心理阴影:递归、正则表达式、动态规划——这三个导致让我怀疑智商怀疑人生。
在这次假期刷题的时候,前两个似乎都已经不是问题了,就差动态规划——昨天不行random到一道题,一眼望着就是动态规划了——可是我不会啊。
You are given coins of different denominations and a total amount of money amount. Write a function to compute 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.
题目来自LeetCode,本来是不准备写LeetCode的题了,全都在GitHub上了大家看看就行了,不过这题有助于让我们更好地理解(第一次理解)动态规划。