下面的贪心代码一定能对任意硬币面值集合 coins 求出 money 所需的最少硬币数。 int count = 0; for (int coin : coins) { // coins 按面值从大到小排列 count += money / coin; money %= coin; }