leetcode-71-简化路径
题目描述:
方法:
class Solution: def simplifyPath(self, path: str) -> str: stack = [] path = path.split("/") for item in path: if item == "..": if stack : stack.pop() elif item and item != ".": stack.append(item) return "/" + "/".join(stack)