# Simplify Path (Leetcode 71)

Problem Link: <https://leetcode.com/problems/simplify-path/>

```python
class Solution:
    def simplifyPath(self, path: str) -> str:
        
        arr=list(map(str,path.split('/')))
        s=[]
        for i in range(len(arr)):
            if(arr[i]=='' or arr[i]=='.'):
                continue
            
            if(arr[i]=='..'):
                if(len(s)>0):
                    s.pop()
                else:
                    continue
            
            else:
                s.append(arr[i])
        
        ans='/'
        if(len(s)==0):
            return ans
        for i in range(len(s)):
            if(i==len(s)-1):
                ans=ans+s[i]
            else:
                ans=ans+s[i]+'/'
        
        return ans
            
            
        
```
