leetcode71. 简化路径
class Solution: def simplifyPath(self, path: str) -> str: li=path.split("/") res=[] for i in li: if i=='..' and res: res.pop() if i!='.' and i!='..' and set(i)!=set(''): res.append(i) return '/'+"/".join(res)
class Solution: def simplifyPath(self, path: str) -> str: li=path.split("/") res=[] for i in li: if i=='..' and res: res.pop() if i!='.' and i!='..' and set(i)!=set(''): res.append(i) return '/'+"/".join(res)