栈,将 s 根据 "/" 分割, 遇到 "" 或 "." 不入栈, 遇到 ".." 且栈有值的情况下,栈顶出栈

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param path string字符串 
# @return string字符串
#
class Solution:
    def simplifyPath(self , path: str) -> str:
        # write code here
        stack = []
        for p in path.split("/"):
            if p == "" or p == ".":
                continue
            if p == "..":
                if stack:
                    stack.pop()
            else:
                stack.append(p)
        return "/" + "/".join(stack)