Level: Intern
Round: Online Assessment · Type: Coding · Difficulty: 6/10
Topics: In-memory database, Data structures, Algorithms, String manipulation
Location: San Francisco, CA
Interview date: 2024-01-29
Got offer: False
The online assessment involved implementing a simplified in-memory database. It consisted of four levels, each building upon the previous one. Level 1 required implementing basic operations to manipulate records, fields, and values. Level 2 added filtering capabilities. Level 3 introduced TTL settings for records, and Level 4 required supporting look-back operations to retrieve values at specific timestamps.
The online assessment required me to implement a simplified in-memory database with the following functionalities:
Level 1: Basic operations to manipulate records, fields, and values within fields.
SET <timestamp> <key> <field> <value>: Inserts a field-value pair into the record associated with the key.COMPARE_AND_SET <timestamp> <key> <field> <expectedValue> <newValue>: Updates the value of a field if the current value equals the expected value.COMPARE_AND_DELETE <timestamp> <key> <field> <expectedValue>: Removes a field if its value equals the expected value.GET <timestamp> <key> <field>: Returns the value of a field in a record.Level 2: Support displaying a record's fields based on a filter.
Level 3: Support TTL (Time-To-Live) settings for records.
Level 4: Support look-back operations to retrieve values stored at a specific timestamp in the past.
The input is an array of queries, and the output should be an array of strings representing the returned values of all queries. Each query calls only one operation.
Here's an example of how the operations should work:
` Queries queries = [ ["SET", "0", "A", "B", "4"], ["SET", "1", "A", "C", "6"], ["COMPARE_AND_SET", "2", "A", "B", "4", "9"], ["COMPARE_AND_SET", "3", "A", "C", "4", "9"], ["COMPARE_AND_DELETE", "4", "A", "C", "6"], ["GET", "5", "A", "C"], ["GET", "6", "A", "B"] ]
Returns ["", "", "true", "false", "true", "", "9"] `