This question evaluates implementation skills for an in-memory SQL-like table, focusing on data modeling with nested key-value structures, string handling, efficient lookups, and lexicographic sorting with tie-breaking.
Implement a simple in-memory database for one table. All values are strings.
Each row is identified by a rowKey (string). Each row contains columns identified by colKey (string).
You must process a sequence of commands and output results for read/query commands.
SET rowKey colKey value
table[rowKey][colKey] = value
.
GET rowKey colKey
NULL
.
SELECT whereCol whereValue orderByCol
table[rowKey][whereCol] == whereValue
.
orderByCol
in
ascending lexicographic order
.
orderByCol
, treat its sort value as an empty string
""
.
orderByCol
value, break ties by
rowKey
ascending.
rowKey
s joined by a single space (or output an empty line if none).
GET
, print a single line.
SELECT
, print a single line.