Advertisement
Iam_Sandeep

71. Simplify Path

Jul 22nd, 2022
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. class Solution:
  2.     def simplifyPath(self, path: str) -> str:
  3.         st=[]
  4.         for token in path.split('/'):
  5.             if token=='.' or token=='':
  6.                 continue
  7.             elif token=='..':
  8.                 if st:st.pop()
  9.             else:
  10.                 st.append(token)
  11.         return '/'+'/'.join(st)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement