Leetcode 71. Simplify Path | | Leetcode 71. Simplify Path 文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Description 2. Solution Version 1 123456789101112131415class Solution: def simplifyPath(self, path: str) -> str: result = [] data = path.split('/') for temp in data: if temp == '' or temp == '.': continue elif temp == '..': if len(result) != 0: result.pop() else: result.append(temp) result = '/' + '/'.join(result) return result Reference https://leetcode.com/problems/simplify-path/ 如果有收获,可以请我喝杯咖啡! 赏 微信打赏 支付宝打赏