mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
添加 0518.零钱兑换II.md Scala版本
This commit is contained in:
@ -289,7 +289,22 @@ function change(amount: number, coins: number[]): number {
|
||||
};
|
||||
```
|
||||
|
||||
Scala:
|
||||
|
||||
```scala
|
||||
object Solution {
|
||||
def change(amount: Int, coins: Array[Int]): Int = {
|
||||
var dp = new Array[Int](amount + 1)
|
||||
dp(0) = 1
|
||||
for (i <- 0 until coins.length) {
|
||||
for (j <- coins(i) to amount) {
|
||||
dp(j) += dp(j - coins(i))
|
||||
}
|
||||
}
|
||||
dp(amount)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
-----------------------
|
||||
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
||||
|
Reference in New Issue
Block a user