Hints — p100 Design In-Memory File System

  1. Model: a trie of nodes. Each Node has children: dict[str, Node] and content: str (empty = directory).

  2. Path parsing: [p for p in path.split("/") if p]. Root "/" yields [].

  3. Single _walk(parts, create) helper drives all four ops: ls, mkdir, addContentToFile, readContentFromFile. Code duplication is the smell.

  4. ls on a file returns [filename], not directory listing. Check node.content != "".

  5. addContentToFile appends, doesn’t overwrite. And it must auto-create intermediate directories.

If stuck: see solution.py.