Skip to content

Commit c475582

Browse files
authored
unique paths solution
1 parent eef9a1d commit c475582

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

unique-paths/yhkee0404.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
fun uniquePaths(m: Int, n: Int): Int {
3+
val dp = List(m + 1) {MutableList(n + 1) {0}}
4+
dp[0][1] = 1
5+
for (i in 1..m) {
6+
for (j in 1..n) {
7+
dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
8+
}
9+
}
10+
return dp.last().last()
11+
}
12+
}

0 commit comments

Comments
 (0)