Skip to content

Commit f090d83

Browse files
authored
Update 62.unique-paths.md
1 parent 61a1b45 commit f090d83

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

problems/62.unique-paths.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,25 @@ class Solution:
9191

9292
当然你也可以使用记忆化递归的方式来进行,由于递归深度的原因,性能比上面的方法差不少:
9393

94-
> 直接暴力递归的话会超时
94+
> 直接暴力递归的话可能会超时
9595
9696
Python3 Code:
9797

9898
```python
9999
class Solution:
100-
visited = dict()
101-
100+
101+
@lru_cache
102102
def uniquePaths(self, m: int, n: int) -> int:
103-
if (m, n) in self.visited:
104-
return self.visited[(m, n)]
105103
if m == 1 or n == 1:
106104
return 1
107105
cnt = self.uniquePaths(m - 1, n) + self.uniquePaths(m, n - 1)
108-
self.visited[(m, n)] = cnt
109106
return cnt
110107
```
111108

109+
112110
## 关键点
113111

112+
- 排列组合原理
114113
- 记忆化递归
115114
- 基本动态规划问题
116115
- 空间复杂度可以进一步优化到 O(n), 这会是一个考点

0 commit comments

Comments
 (0)