Cloud File System

Asked at Meta

Reported by the problem's creator, not verified

Build an in-memory cloud file system, CloudStorage. Every file has a unique name and a positive integer size.

Examples

  1. Example 1

    Input: init = [], operations = [["add_file",["a/x",30]],["add_file",["a/x",5]],["get_file_size",["a/x"]],["get_file_size",["none"]],["delete_file",["a/x"]],["delete_file",["a/x"]],["get_file_size",["a/x"]],["add_file",["a/x",7]],["get_file_size",["a/x"]]]

    Output: [true,false,30,null,30,null,null,true,7]

    Explanation: The second add_file for a/x returns false and the size stays 30. delete_file returns 30 once and null the second time. After that the name is free, so adding it with size 7 works.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.