We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32f43a4 commit 60d0ed2Copy full SHA for 60d0ed2
unique-paths/yyyyyyyyyKim.py
@@ -0,0 +1,13 @@
1
+class Solution:
2
+ def uniquePaths(self, m: int, n: int) -> int:
3
+
4
+ # DP (시간복잡도 O(m*n), 공간복잡도 O(m*n))
5
+ # 모든 1행과 1열은 경로가 1개이므로 1로 배열 초기화.
6
+ dp = [[1]*n for _ in range(m)]
7
8
+ for i in range(1,m):
9
+ for j in range(1,n):
10
+ # 현재위치 경로 경우의 수 = 위쪽 + 왼쪽
11
+ dp[i][j] = dp[i-1][j] + dp[i][j-1]
12
13
+ return dp[m-1][n-1]
0 commit comments