注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
这个题目还没怎么在地里看到过,贡献一个DP。OA2全程proctoring。祝大家面试成功!求加米
Your task is to implement a simple cloud storage system, All operatlons that should be supported are listed below.
Requirements
Your task is to implement a simple cloud storage system that maps objects (files) to their meta information. Specifically, the storage should maintain files and information about them (name, size, etc.). Note that this system should be In-memory: you don't need to work with the real filesystem.
Level 1: The cloud storage system should support adding a new flie and retrieving and deleting files.
Level 2: The cloud storage system should support displaying the largest files.
Level 3: The cloud storage system should support adding users with limited capacities and merging two users
Level 4: The cloud storage system should support backing up restoring a user's files
Level 1
The cloud storage system should support file manipulation.
add file(self, name: str, size: int) -> bool -should add a new file name to the storage. size is the amount of memory required in bytes. The current operation fails if a file with the same name alueries, Overwrites any backups for the same user if previous backups exist. Return the number of backed-up files, or None if user_id does not exist
restore user(self, user id; str) -> int I None should restore the state of user_id 's files to the latest backup, If there was no backup, all of user id 's files are deleted. If a file can't be restored because another user added another file with the same name, it ls ignored. Returns the number of the files that are successfully restored or None if user id does not exist.
Note that merge user does not affect user id 1 's backup, and user id 2 is deleted along with its backup
Note that the restore_user operation does not affect the user's capacity
|