Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def simplifyPath(self, path: str) -> str:
- deslashed = path.split('/')
- stack = []
- for s in deslashed:
- if s == '.':
- continue
- elif s == '..':
- if len(stack) > 0:
- stack.pop()
- elif s != '':
- stack.append(s)
- return "/" + "/".join(stack)
Advertisement
Add Comment
Please, Sign In to add comment