---
title: "71. Simplify Path"
url: "https://laigary.com/interview/coding/71-simplify-path"
type: "note"
section: "coding"
date: "2025-04-02"
updated: "2025-04-02"
tags: ["Stack"]
---

# 71. Simplify Path

[71\. Simplify Path](https://leetcode.com/problems/simplify-path/)

```python
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)
```
