4 Star 25 Fork 17

编程语言算法集 / Go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
coinchange.go 391 Bytes
一键复制 编辑 原始数据 按行查看 历史
nursyah21 提交于 2022-04-21 19:37 . added implementation coinchange (#496)
package dynamic
// CoinChange finds the number of possible combinations of coins
// of different values which can get to the target amount.
func CoinChange(coins []int32, amount int32) int32 {
combination := make([]int32, amount)
combination[0] = 1
for _, c := range coins {
for i := c; i < amount; i++ {
combination[i] += combination[i-c]
}
}
return combination[amount-1]
}
Go
1
https://gitee.com/TheAlgorithms/Go.git
git@gitee.com:TheAlgorithms/Go.git
TheAlgorithms
Go
Go
master

搜索帮助