mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
@ -226,11 +226,11 @@ func coinChange1(coins []int, amount int) int {
|
||||
for i := 0; i < len(coins); i++ {
|
||||
// 遍历背包
|
||||
for j := coins[i]; j <= amount; j++ {
|
||||
//if dp[j-coins[i]] != math.MaxInt32 {
|
||||
if dp[j-coins[i]] != math.MaxInt32 {
|
||||
// 推导公式
|
||||
dp[j] = min(dp[j], dp[j-coins[i]]+1)
|
||||
fmt.Println(dp,j,i)
|
||||
//}
|
||||
//fmt.Println(dp,j,i)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 没找到能装满背包的, 就返回-1
|
||||
|
Reference in New Issue
Block a user