71. Simplify Path
# Medium
Key idea:
extract the string between start
'/'
and end'/'
storing in a string list(only effctive path)"."
do nothing".."
path2.pop()
Solution:
find the effective start
'/'
find the effective end
'/'
, extract string between start and endif string =
'.'
, do nothing; if string ='..'
,path2.pop()
; elsepath2.append(string)
convert
path2
list to a real path string
Last updated