You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This discussion was converted from issue #149 on September 15, 2026 11:13.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/simplify-path/
Problem Summary
unix path가 주어질 때 간단화 하는 문제.
즉, 여러 슬래시나 .. 같은 디렉토리 변경 등을 다 처리후 최소화된 경로로 만드는 문제.
Solution
스택을 쓰면 되는 간단한 문제.
먼저 슬래시 기준으로 split을 해준다. 일반적인
.,..같은 디렉토리 명렁어가 아닌 경우 스택에 넣어주고,..의 경우에는 스택에서 빼주면 된다. 비어있는 문자열은 연속된 슬래시이므로 무시하면 된다.마지막으로 슬래시로 시작되어야 하므로
/를 맨 앞에 넣고 리턴하면 된다.Source Code
All reactions