bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 588. Design In-Memory File System

588. Design In-Memory File System

Leetcode Solutions

Using Separate Directory and File Structures

  1. Initialize a root directory with empty dirs and files hashmaps.
  2. For ls, split the path, navigate to the target directory or file, and return the appropriate list or file name.
  3. For mkdir, split the path, navigate to the last existing directory, and create new directories as needed.
  4. For addContentToFile, split the path, navigate to the target file's directory, and either create a new file or append to an existing file.
  5. For readContentFromFile, split the path, navigate to the file, and return its contents.
UML Thumbnail

Using Unified Directory and File Structure

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...
bugfree Icon
OR