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 61a1b45 commit f090d83Copy full SHA for f090d83
problems/62.unique-paths.md
@@ -91,26 +91,25 @@ class Solution:
91
92
当然你也可以使用记忆化递归的方式来进行,由于递归深度的原因,性能比上面的方法差不少:
93
94
-> 直接暴力递归的话会超时。
+> 直接暴力递归的话可能会超时。
95
96
Python3 Code:
97
98
```python
99
class Solution:
100
- visited = dict()
101
-
+
+ @lru_cache
102
def uniquePaths(self, m: int, n: int) -> int:
103
- if (m, n) in self.visited:
104
- return self.visited[(m, n)]
105
if m == 1 or n == 1:
106
return 1
107
cnt = self.uniquePaths(m - 1, n) + self.uniquePaths(m, n - 1)
108
- self.visited[(m, n)] = cnt
109
return cnt
110
```
111
112
## 关键点
113
+- 排列组合原理
114
- 记忆化递归
115
- 基本动态规划问题
116
- 空间复杂度可以进一步优化到 O(n), 这会是一个考点
0 commit comments