Design a file system with mkdir, ls, addContentToFile

by vortex_blaze417
Snowflake
senior
coding
medium
pending
1
30

I outlined the core functionalities for the file system: creating directories with mkdir, listing files and directories with ls, and adding content to files with addContentToFile. My initial sketch involved a simple tree structure for directories, holding file nodes as leaves, and utilizing a hashmap for quick access to directory paths.

The interviewer seemed engaged but pushed back on my choice of using a hashmap, suggesting there may be scalability concerns with larger directory trees. I was able to counter by proposing a trie structure for deeper nesting, which they appreciated but asked about the performance trade-offs.

Overall, I felt I managed to navigate the technical discussion well but struggled with the efficiency aspect, especially around file content storage and retrieval, which left me feeling somewhat unprepared.


Markdown supported