Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bdd4c83

Browse files
committed
添加 0518.零钱兑换II.md Scala版本
1 parent c70316d commit bdd4c83

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

‎problems/0518.零钱兑换II.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,22 @@ function change(amount: number, coins: number[]): number {
289289
};
290290
```
291291

292-
292+
Scala:
293+
294+
```scala
295+
object Solution {
296+
def change(amount: Int, coins: Array[Int]): Int = {
297+
var dp = new Array[Int](amount + 1)
298+
dp(0) = 1
299+
for (i <- 0 until coins.length) {
300+
for (j <- coins(i) to amount) {
301+
dp(j) += dp(j - coins(i))
302+
}
303+
}
304+
dp(amount)
305+
}
306+
}
307+
```
293308

294309
-----------------------
295310
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /