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 a1828aa commit bba4a94Copy full SHA for bba4a94
โunique-paths/hu6r1s.pyโ
@@ -0,0 +1,23 @@
1
+class Solution:
2
+ """
3
+ dfs๋ก ํ๋ฉด ๋ ๊ฒ์ด๋ผ๊ณ ์๊ฐ์ ํ์ง๋ง ์ด์ ๋ฌธ์ ์ ๊ฐ์ ๋ฐฉ์์ผ ์ค ์์๋๋ฐ ์ด๋ฌํ ๋ฐฉ์์ด ์๋ ๊ฒ์ ์์์
4
5
+ # def uniquePaths(self, m: int, n: int) -> int:
6
+ # def dfs(x, y):
7
+ # if x == m - 1 and y == n - 1:
8
+ # return 1
9
+ # if x >= m or y >= n:
10
+ # return 0
11
+
12
+ # return dfs(x + 1, y) + dfs(x, y + 1)
13
14
+ # return dfs(0, 0)
15
16
+ def uniquePaths(self, m: int, n: int) -> int:
17
+ dp = [[1] * n for _ in range(m)]
18
19
+ for row in range(1, m):
20
+ for col in range(1, n):
21
+ dp[row][col] = dp[row - 1][col] + dp[row][col - 1]
22
23
+ return dp[-1][-1]
0 commit comments