题目描述:
方法:
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)
2024-02-10 20:22:04
题目描述:
方法:
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)