Roots and Branches
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L5
Problem
A storage indexer hands you object keys as slash-separated `paths`, and you need them folded into a nested dict that mirrors the directory layout: every directory segment maps to an inner dict and every file (the final segment) maps to `None`. Paths that share a leading directory must collapse onto the same node instead of clobbering each other, and an empty list yields an empty dict.
Summary
Flat strings carry a hierarchy. Recover it.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.