~/problems

Problems

Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.

Stacks

Stack: path parsing

Resolve ., .. and symlinks with a stack.

Notes

Recognise it when: path normalization, nested structures, undo, "most recent unmatched".

parts = [] if path.startswith("/") else cwd_parts[:]
for comp in path.split("/"):
    if comp in ("", "."): continue
    if comp == "..":
        if parts: parts.pop()
    else:
        parts.append(comp)
return "/" + "/".join(parts)

Symlinks: after each append, if the built path is a link, replace the whole stack with the resolved target (relative to the link's parent). Keep an "expanding" set to catch loops.

8 problems

Interview roadmap

Stacks Matching brackets, paths, next greater element.

Stack: path parsing guide

esc