mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-03 19:52:01 +08:00
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
24 lines
548 B
Go
24 lines
548 B
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)
|
|
}
|