Skip to content

Commit 06aa8e3

Browse files
committed
Add unique paths solution
1 parent c6aa537 commit 06aa8e3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

unique-paths/hyunjung-choi.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 시간 복잡도: O(m * n)
3+
* 공간 복잡도: O(n)
4+
*/
5+
6+
class Solution {
7+
fun uniquePaths(m: Int, n: Int): Int {
8+
val dp = IntArray(n) { 1 }
9+
10+
for (i in 1 until m) {
11+
for (j in 1 until n) {
12+
dp[j] += dp[j - 1]
13+
}
14+
}
15+
16+
return dp[n - 1]
17+
}
18+
}

0 commit comments

Comments
 (0)