← 返回 coinbase 的题目列表In-Memory File System Design
类型:online_judge
Design an in-memory file system that supports user operations. The file system should have the following functionalities:
Add a file: Add a file for a specified user, with content as an arbitrary string.
Delete a file: Delete a specified file for a user.
Copy a file: Copy a file within the same user, allowing specification of a new filename.
Ensure to support the above basic operations and gradually introduce new functionalities (such as file searching, user permissions management, etc.) with backward compatibility. All new methods must be compatible with previous operations and update test cases. Design a data structure for efficient operations and implement all methods.
Test cases:
Add a file and read it.
Add and copy a file, ensuring the copied file content is correct.
Attempt to read a file after deletion.
Backtrack testing after new functionalities to ensure all old functions still operate normally.
Data scale: Assume support for up to 10,000 users, with each user owning up to 1,000 files.
Example
Input
add_file(user1, 'file1', 'content1')\nread_file(user1, 'file1')