mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
添加 0062.不同路径.md Scala版本
This commit is contained in:
@ -412,5 +412,21 @@ int uniquePaths(int m, int n){
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Scala
|
||||||
|
|
||||||
|
```scala
|
||||||
|
object Solution {
|
||||||
|
def uniquePaths(m: Int, n: Int): Int = {
|
||||||
|
var dp = Array.ofDim[Int](m, n)
|
||||||
|
for (i <- 0 until m) dp(i)(0) = 1
|
||||||
|
for (j <- 1 until n) dp(0)(j) = 1
|
||||||
|
for (i <- 1 until m; j <- 1 until n) {
|
||||||
|
dp(i)(j) = dp(i - 1)(j) + dp(i)(j - 1)
|
||||||
|
}
|
||||||
|
dp(m - 1)(n - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
|
<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