~/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.
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
- Basics: balanced brackets with a stack basics py · c++ · java easy
- Where each piece of text lives py · c++ · java easy
- Simplify Path py · c++ · java easy
- OA: cd with ~ and symlinks 3 levels OpenAI hard
- OA: Stack trace reconstruction 3 levels Anthropic medium
- OA: Fewest deletions to balance parentheses 2 levels DoorDash easy
- CPU usage analysis Uber medium
- Longest valid ranked-bracket substring Uber py · c++ · java hard