Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution(object):
- def lengthLongestPath(self, input):
- """
- :type input: str
- :rtype: int
- """
- string = input.split("\n")
- lst = []
- longest_string = ""
- for s in string:
- count = s.count('\t')
- if (count > 0):
- index = s.rfind('\t') # find last occurenct of \t
- s = s[index+1:]
- if count < len(lst):
- lst[count] = s
- lst = lst[:count + 1]
- else:
- lst.append(s)
- curr_string = "/".join(lst)
- if len(curr_string) > len(longest_string) and "." in curr_string:
- longest_string = curr_string
- return len(longest_string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement