class Solution(object):
def simplifyPath(self, path):
"""
:type path: str
:rtype: str
"""
stack = []
for cur_dir in path.split("/"):
if cur_dir == "..":
if stack:
stack.pop()
elif cur_dir != "." and cur_dir != "":
stack.append(cur_dir)
return "/" + "/".join(stack)