diff --git a/articles/simplify-path.md b/articles/simplify-path.md index 75f4e016f..f57c573cb 100644 --- a/articles/simplify-path.md +++ b/articles/simplify-path.md @@ -30,18 +30,19 @@ A Unix-style path can contain special directory references: `.` means the curren class Solution: def simplifyPath(self, path: str) -> str: stack = [] - cur = "" + cur = [] for c in path + "/": if c == "/": + cur = "".join(cur) if cur == "..": if stack: stack.pop() elif cur != "" and cur != ".": stack.append(cur) - cur = "" + cur = [] else: - cur += c + cur.append(c) return "/" + "/".join(stack) ```