mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 01:36:30 +08:00
c1adeb2399
* feat(go/dp): support climbing stairs * feat(go/dp): support knapsack * feat(go/dp): coin_change & edit_distance
23 lines
506 B
Go
23 lines
506 B
Go
// File: coin_change_test.go
|
|
// Created Time: 2023-07-23
|
|
// Author: Reanon (793584285@qq.com)
|
|
|
|
package chapter_dynamic_programming
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestCoinChange(t *testing.T) {
|
|
coins := []int{1, 2, 5}
|
|
amt := 4
|
|
|
|
// 动态规划
|
|
res := coinChangeDP(coins, amt)
|
|
fmt.Printf("凑到目标金额所需的最少硬币数量为 %d\n", res)
|
|
|
|
// 状态压缩后的动态规划
|
|
res = coinChangeDPComp(coins, amt)
|
|
fmt.Printf("凑到目标金额所需的最少硬币数量为 %d\n", res)
|
|
}
|