Testing Dynamic Programming Coin Change Algorithms in hello-algo
This test suite evaluates coin change algorithms implemented using dynamic programming in Go. It validates both standard and space-optimized approaches for finding the minimum number of coins needed to make up a target amount.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
krahets/hello-algo
zh-hant/codes/go/chapter_dynamic_programming/coin_change_test.go
// File: coin_change_test.go
// Created Time: 2023-07-23
// Author: Reanon ([email protected])
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)
}