My Python solution

  • 1

    here is my python solution. The algorithm is simple using stack

    def simplifyPath(self, path):
            z = path.split("/")
            z = filter(lambda x: x != "" and x != ".",z)
            s = list();
            for x in z:
            	if(x != ".."):
            	elif s:
            result = "/".join(s)
            return "/"+result

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.