Question DSA-STK-0064
HardWhat is the output of this code?
def simplify(p):
st = []
for part in p.split("/"):
if part == "..":
if st: st.pop()
elif part and part != ".":
st.append(part)
return "/" + "/".join(st)
print(simplify("/a/./b/../../c/"), simplify("/../x//y/"))
- A.
/a/b/c /x/y
- B.
/a/c /x/y
- C.
Sign up free to see the answer and a step-by-step explanation.