LC: 588. Design In Memory File System - spiralgo/algorithms GitHub Wiki

588. Design In-Memory File System:

The Essence: The aim of this question:

  • Teaching how to design a class in the programming language of choice.
  • Teaching to use String manipulations, String list, etc.

Details:

The common problem here is finding the file or the directory. Hence, it's only most convenient to create a separate method for it. We simply get the pathname and split it into strings originally separated by '/'. From the root directory, which we are keeping, we simply traverse down to the sought folder using the maps of the directories. We also create new directories when we can't find the directory name we had in the paths string.

Here is the corresponding PR: https://github.com/spiralgo/algorithms/pull/387