mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-25 12:14:26 +08:00
Add solution 0279、0518
This commit is contained in:
12
leetcode/0518.Coin-Change-2/518. Coin Change 2.go
Normal file
12
leetcode/0518.Coin-Change-2/518. Coin Change 2.go
Normal file
@ -0,0 +1,12 @@
|
||||
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]
|
||||
}
|
Reference in New Issue
Block a user