Created
November 24, 2014 09:59
-
-
Save rohith2506/8f47759e7f6200d149c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
# @param path, a string | |
# @return a string | |
def simplifyPath(self, path): | |
result = [] | |
pathList = path.split('/') | |
for content in pathList: | |
if content: | |
if content == '..': | |
try: | |
result.pop() | |
except: | |
result = [] | |
elif content != '.': | |
result.append(content) | |
return '/'+'/'.join(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment