Cloud Storage System

Asked at AirbnbOnline assessment

Reported by the problem's creator, not verified

You are building an in-memory cloud storage system as the class CloudStorage. A file has a unique name and a size.

Examples

  1. Example 1

    Input: init = [], operations = [["add_file",["a.txt",10]],["add_file",["b.txt",5]],["add_file",["a.txt",99]],["get_file_size",["a.txt"]],["get_file_size",["zzz"]],["delete_file",["a.txt"]],["delete_file",["a.txt"]],["get_file_size",["a.txt"]],["add_file",["a.txt",7]],["get_file_size",["a.txt"]]]

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

    Explanation: The second add of a.txt fails because the name exists. Reading a missing file gives null. Deleting a.txt returns its size 10; deleting it again gives null, and the name can be added again with a new size.

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.