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 8e27191

Browse files
committed
添加 0062.不同路径.md Scala版本
1 parent fe3aa4f commit 8e27191

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎problems/0062.不同路径.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,5 +412,21 @@ int uniquePaths(int m, int n){
412412
}
413413
```
414414
415+
### Scala
416+
417+
```scala
418+
object Solution {
419+
def uniquePaths(m: Int, n: Int): Int = {
420+
var dp = Array.ofDim[Int](m, n)
421+
for (i <- 0 until m) dp(i)(0) = 1
422+
for (j <- 1 until n) dp(0)(j) = 1
423+
for (i <- 1 until m; j <- 1 until n) {
424+
dp(i)(j) = dp(i - 1)(j) + dp(i)(j - 1)
425+
}
426+
dp(m - 1)(n - 1)
427+
}
428+
}
429+
```
430+
415431
-----------------------
416432
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>

0 commit comments

Comments
(0)

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