mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-07 01:44:56 +08:00
13 lines
218 B
Go
13 lines
218 B
Go
package leetcode
|
|
|
|
func change(amount int, coins []int) int {
|
|
dp := make([]int, amount+1)
|
|
dp[0] = 1
|
|
for _, coin := range coins {
|
|
for i := coin; i <= amount; i++ {
|
|
dp[i] += dp[i-coin]
|
|
}
|
|
}
|
|
return dp[amount]
|
|
}
|