← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design and implement a lightweight in-memory database that supports adding rows, sorting by a column, filtering by column values, and clearing filters. The database must maintain insertion order for rows that are not affected by sort/filter operations. You must expose the following public methods:
addRow(rowId: str, columns: dict[str, Any]) -> None – Insert or update a row. If rowId already exists, overwrite the columns. The rowId is unique.sortBy(column: str, ascending: bool = True) -> None – Sort the visible rows by the specified column. Sorting must be stable (preserve relative order of rows that compare equal). Rows that do not have the specified column must appear at the end regardless of ascending or descending order.filterWhere(column: str, value: Any) -> None – Restrict the visible rows to only those where the specified column equals the given value. Multiple filters are composable (i.e., applying a new filter further restricts the current view). Filters do not affect the underlying storage.clearFilters() -> None – Remove all active filters and restore visibility to all rows (subject to the last sort order).getView() -> list[str] – Return a list of strings representing the currently visible rows in their current order. Each string must be formatted as a space-separated sequence of col=val pairs, with column names sorted alphabetically. Missing columns in a row must be omitted. Values must be converted to strings; if a column contains mixed types (e.g., int and str), compare and format them as strings.