Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe62196

Browse files
Update README.md
1 parent 06c7d0f commit fe62196

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,15 @@ class Solution:
630630
- dp递归方程:到达当前楼梯的路径数 = 到达上个楼梯的路径数 + 到达上上个楼梯的路径数
631631
- 这里用一个元组 r 来储存(当前楼梯路径数,下一层楼梯路径数)
632632
- 利用 reduce 来代替for循环。[reduce 函数详解](https://www.cnblogs.com/XXCXY/p/5180245.html)
633+
## [71. Simplify Path 4行](https://leetcode.com/problems/simplify-path/)
634+
```
635+
class Solution:
636+
def simplifyPath(self, path: str) -> str:
637+
r = []
638+
for s in path.split('/'):
639+
r = {'':r, '.':r, '..':r[:-1]}.get(s, r + [s])
640+
return '/' + '/'.join(r)
641+
```
633642
## [78. Subsets 2行](https://leetcode.com/problems/subsets/)
634643
```python
635644
class Solution:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /