Thanks to visit codestin.com Credit goes to github.com
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 d71918e commit 3dc25f9Copy full SHA for 3dc25f9
problems/62.unique-paths.md
@@ -117,6 +117,10 @@ class Solution:
117
- 空间复杂度可以进一步优化到O(n), 这会是一个考点
118
## 代码
119
120
+代码支持JavaScript,Python3
121
+
122
+JavaScript Code:
123
124
```js
125
/*
126
* @lc app=leetcode id=62 lang=javascript
@@ -143,6 +147,19 @@ var uniquePaths = function(m, n) {
143
147
};
144
148
```
145
149
150
+Python3 Code:
151
152
+```python
153
+class Solution:
154
155
+ def uniquePaths(self, m: int, n: int) -> int:
156
+ dp = [1] * n
157
+ for _ in range(1, m):
158
+ for j in range(1, n):
159
+ dp[j] += dp[j - 1]
160
+ return dp[n - 1]
161
+```
162
146
163
**复杂度分析**
164
165
- 时间复杂度:$O(M * N)$
0 commit comments