← 返回 bytedance 的题目列表Leetcode 588 Problem
类型:online_judge
Design an in-memory file system to support the creation of paths, adding content to files, and reading file content. The operations to support are:
Create a path.
Add content to a file.
Read content from a file.
Example:
Input: commands = ["mkdir", "/a/b/c", "addContentToFile", "/a/b/c/d", "hello", "readContentFromFile", "/a/b/c/d"]
Output: [null, null, "hello"]
Explanation:
In the sequence of file system commands:
- "mkdir /a/b/c" creates a path named "/a/b/c".
- "addContentToFile /a/b/c/d, hello" adds the file content "hello" at file path "/a/b/c/d".
- "readContentFromFile /a/b/c/d" returns the content of the file path "/a/b/c/d", which is "hello".
Example
Input
mkdir /a/b/c
addContentToFile /a/b/c/d hello
readContentFromFile /a/b/c/d