Implement string-path file system operations
Company: DoorDash
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates competency in designing data structures for hierarchical string-path file systems, including string parsing, stateful API semantics, validation logic, and efficient lookup/update operations.
Constraints
- 1 <= len(ops) <= 50000
- Sum of path lengths across all operations <= 2e6
- Each value is a 32-bit signed integer
- Paths use '/' as separator, start with '/', have no empty segments, and do not end with '/' unless the path is exactly '/'
- Root '/' exists initially and cannot be created, set, or deleted
- Create requires the immediate parent of the path to exist and the path to not already exist
Hints
- Store the directory tree as nested hash maps (a trie-like structure).
- Validate path format before performing any operation.
- For Create, traverse to the parent; for Set/Get/Delete, traverse to the exact node.
- Delete can be implemented by removing the child entry from its parent's map.