← Questions
Simplified filesystem with paths and traversal
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Implement a small filesystem with path lookup and directory traversal, extended in the final level with model-related behavior. The harness is strict, so edge cases around paths matter.
-
Level 1:
mkdir(path)(creates parents),write(path, content),read(path),ls(path). -
Level 2:
rm(path)(recursive, never/),mv(src, dst). -
Level 3:
find(path, suffix="")anddu(path). -
Level 4: checkpoints named
step-<n>.ckpt:latest_checkpoint(dir)andprune_checkpoints(dir, keep).
class FileSystem:
def mkdir(self, path): ...
def write(self, path, content): ...
def read(self, path): ...
def ls(self, path): ...
def rm(self, path): ...
def mv(self, src, dst): ...
def find(self, path, suffix=""): ...
def du(self, path): ...
def latest_checkpoint(self, path): ...
def prune_checkpoints(self, path, keep): ...
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
