Version 1: Top-down approach using recursion
(coins []int, amount int)
| 70 | |
| 71 | // Version 1: Top-down approach using recursion |
| 72 | func coinChangeTopDown(coins []int, amount int) int { |
| 73 | if len(coins) == 0 || amount < 1 { |
| 74 | return -1 |
| 75 | } |
| 76 | return minChange(coins, amount, make([]int, amount)) |
| 77 | } |
| 78 | |
| 79 | func minChange(coins []int, rem int, memo []int) int { |
| 80 | if rem < 0 { |
nothing calls this directly
no test coverage detected