| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- t1
- Substring with Concatenation of All Words
- Python Implementation
- 시바견
- concurrency
- 운영체제
- 밴픽
- Class
- Generator
- 프로그래머스
- Python Code
- 30. Substring with Concatenation of All Words
- data science
- Decorator
- 109. Convert Sorted List to Binary Search Tree
- iterator
- 715. Range Module
- LeetCode
- 파이썬
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
- DWG
- kaggle
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- Python
- shiba
- attribute
- Regular Expression
- Protocol
Archives
- Today
- Total
Scribbling
LeetCode: 71. Simplify Path 본문
class Solution:
def simplifyPath(self, path: str) -> str:
stack = []
paths = path.split('/')
for path in paths:
if path:
if path == '.':
continue
elif path == '..':
if stack:
stack.pop()
else:
stack.append(path)
ret = '/'
for path in stack:
ret += path + '/'
if not stack:
return ret
return ret[:-1]'Computer Science > Coding Test' 카테고리의 다른 글
| LeetCode: 73. Set Matrix Zeroes (0) | 2021.09.28 |
|---|---|
| LeetCode: 72. Edit Distance (0) | 2021.09.26 |
| LeetCode: 69. Sqrt(x) (0) | 2021.09.26 |
| LeetCode: 67. Add Binary (0) | 2021.09.26 |
| LeetCode: 64. Minimum Path Sum (0) | 2021.09.24 |