Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Design In-Memory File System
Bookmark
Hash Map of Paths
Trie
Input
LeetCode Example
Nested Dirs
Simple
Custom
operations
=
[FileSystem, ls, mkdir, addContentToFile, ls, readContentFromFile]
,
values
=
[null, /, /a/b/c, /a/b/c/d|hello, /, /a/b/c/d]
Operation
—
Path
—
Result
—
/
D
Operation
—
Path
—
Result
—
/
D
Operation
ls
Path
"/"
Result
—
/
D
Operation
ls
Path
"/"
Result
[]
/
D
Operation
mkdir
Path
"/a/b/c"
Result
—
/
a
D
D
Operation
mkdir
Path
"/a/b/c"
Result
null (void)
/
a
b
c
D
D
D
D
Operation
addContentToFile
Path
"/a/b/c/d"
Result
—
Content: "hello"
/
a
b
c
d
D
D
D
D
F
Operation
ls
Path
"/"
Result
—
/
a
b
c
d
D
D
D
D
F
Operation
ls
Path
"/"
Result
["a"]
/
a
b
c
d
D
D
D
D
F
Operation
readContentFromFile
Path
"/a/b/c/d"
Result
—
/
a
b
c
d
D
D
D
D
F
Operation
readContentFromFile
Path
"/a/b/c/d"
Result
"hello"
Content: "hello"
/
a
b
c
d
D
D
D
D
F
algo
master
.
io
Step:
Initialize In-Memory File System with root directory /
0 / 28
Input
LeetCode Example
Nested Dirs
Simple
Custom
operations
=
[FileSystem, ls, mkdir, addContentToFile, ls, readContentFromFile]
,
values
=
[null, /, /a/b/c, /a/b/c/d|hello, /, /a/b/c/d]
0 / 28
algo
master
.
io
Step:
Initialize In-Memory File System with root directory /