일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 쓰릴오브파이트
- 프로젝트
- 미드시청
- 사이드
- 월간
- 운동
- 영어공부
- 개발자
- 3줄정리
- FIT XR
- Problem Solving
- 영어원서읽기
- 괜찮음
- 링피트
- 만화도
- Writing
- 10분
- 읽기
- 리얼 클래스
- 화상영어
- 파비최
- 매일
- Daily Challenge
- 뭐든
- realclass
- English
- leetcode
- 잡생각
- 30분
- 스탭퍼
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.04.12 Today's Challenge 본문
https://leetcode.com/problems/simplify-path/
Simplify Path - LeetCode
Can you solve this real interview question? Simplify Path - Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in a Unix-style file system, convert it to the simplified canonical path. In a Unix-style file sys
leetcode.com
3일째 스택 관련 문제!
class Solution:
def simplifyPath(self, path: str) -> str:
st = []
path = path.split('/')
for p in path:
if st and p == '..':
st.pop()
elif p not in ['.', '', '..']:
st.append(p)
return '/' + '/'.join(st)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.04.14 Today's Challenge (0) | 2023.04.14 |
---|---|
2023.04.13 Today's Challenge (0) | 2023.04.13 |
2023.04.11 Today's Challenge (0) | 2023.04.11 |
2023.04.10 Today's Challenge (0) | 2023.04.10 |
2023.04.09 Today's Challenge (0) | 2023.04.09 |
Comments