The Design File System interview question asks you to implement a simplified path-based storage system. You need to support createPath(path, value) and get(path). A path is valid only if its parent path already exists. For example, you can't create "/a/b" unless "/a" has already been created. This Design File System coding problem is a variation of prefix-based data storage.
Companies like Uber and Airbnb ask this to test your understanding of Trie interview patterns and hierarchical data. It evaluates how you handle string parsing and whether you can enforce structural constraints (parent existence) during insertion. It’s a test of clean API design and logical validation.
Map<String, Integer> to store the full path string. Before creating "/a/b", check if "/a" exists in the map. This is simple and effective.createPath traverses the Trie and returns an error if a component's parent node isn't found.createPath("/leet", 1): Root has no parent requirement. Map: {"/leet": 1}. Success.createPath("/leet/code", 2): Parent "/leet" exists. Map: {"/leet": 1, "/leet/code": 2}. Success.createPath("/c/d", 3): Parent "/c" does not exist. Return false.get("/leet/code"): Returns 2."/" and failing to handle the resulting empty strings or the root path.get operation when a simple map lookup is after path parsing.While a Hash Map is easier to code, be prepared to discuss the Trie approach. Tries are more space-efficient if many paths share long prefixes and are the standard way real file systems or routers manage hierarchical data.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Implement Trie (Prefix Tree) | Medium | Solve | |
| Implement Trie II (Prefix Tree) | Medium | Solve | |
| Map Sum Pairs | Medium | Solve | |
| Implement Magic Dictionary | Medium | Solve | |
| Design In-Memory File System | Hard | Solve |