class Solution(object): def simplifyPath(self, path): """ :type path: str :rtype: str """ pathList = path.split("/") stack =  for elem in pathList: if elem == '..' and len(stack) != 0: stack.pop() elif elem != '.' and elem != '' and elem != '..': stack.append(elem) return '/' + '/'.join(stack)
My python solution, 56ms. Would interviewer be ok with using the split() function ?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.