Code RoomWrite-ahead log replay
MediumPrep Room Coding #255

Write-ahead log replay

CodingDatabases & SQLMid–Senior~25 min

Recover a key-value store by replaying a write-ahead log, then answer point lookups. The log is a list of records applied in order: ['set', key, value] writes/overwrites a key, ['del', key] removes a key (no-op if absent). After replaying the whole log, answer the given lookup keys, returning each key's value or the string '__ABSENT__' if it is not present in the recovered state. Keys and values are strings. Return a list of values, one per lookup, in order.

Implement
wal_replay(log: list[list], lookups: list[str]) → list[str]
Examples
in[[["set","a","1"],["set","b","2"],["set","a","9"],["del","b"]],["a","b","c"]]out["9","__ABSENT__","__ABSENT__"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
[[["set","a","1"],["set","b","2"],["set","a","9"],["del","b"]],["a","b","c"]]["9","__ABSENT__","__ABSENT__"]not run yetsample