@laigary.com~/interview/coding/71-simplify-path.md$
$ cat ./coding/71-simplify-path.md
[Coding]·2025-04-02·1 min read

71. Simplify Path

71. Simplify Path

class Solution:
    def simplifyPath(self, path: str) -> str:
        
        tmp = path.split('/')
        res = []
        for item in tmp:
            if item == '' or item == '.':
                continue
            elif item == '..':
                if len(res) > 0:
                    res.pop()
            else:
                res.append(item)
        
        return "/" + "/".join(res)
--tags#Stack